Filtering a column

Filtering a column

KumarKumar Posts: 10Questions: 0Answers: 0
edited February 2012 in DataTables 1.8
Hi,

A.I want to filter column where rows doesn't contain any values(i.e blank), and rows contain some value(i.e values might be anything if rows contain value it should not get filter, if rows doesn't contain value that has to be get filter) presently I am using oTable.fnfilter("",columnindex).please keep me in getting this issue resloved.

B.I want to edit my existing table if my condition match for that How to get my datatable individual row to edit for oTable.

Replies

  • KumarKumar Posts: 10Questions: 0Answers: 0
    Hi,

    I have one Question that fnfilter(); doesnot perform operation exactly on data of column,
    Example:
    I have 4 rows

    123.12
    123.12.34
    123.12.34.5
    123.12.34.6


    My Question is If i use oTable.fnfilter('123.12');
    result: I am getting all 4 rows instead of 1 row, Means filter doesnot happening exactly what we required.

    Thanks,
    Kumar
  • allanallan Posts: 54,702Questions: 1Answers: 8,556 Site admin
    fnFilter is doing a substring match - so since your rows all have the required data, they all match. If you want an exact string match you need to use regex: ^123.12$ for example.

    Allan
  • KumarKumar Posts: 10Questions: 0Answers: 0
    Thanks Allan. works fine.

    Kumar
  • KumarKumar Posts: 10Questions: 0Answers: 0
    Hi Allan,

    kumar shop
    Kumar slpshop
    kumar warshop
    kumar kkpshop

    If i filter "kumar shop", I am getting all 4 rows instead of one row(kumar shop).
    Its not filter on particular word.

    Thanks,
    Kumar N
  • koosvdkolkkoosvdkolk Posts: 169Questions: 0Answers: 0
    What is the regex you use?
  • KumarKumar Posts: 10Questions: 0Answers: 0
    oTable.fnFilter("^"+shopName+"$",1,true);

    where shopName is dynamically
    if shopName has (1.kumar shop, 2. kumar KMPshop, 3.kumar MOAshop)

    if I filter based on "kumar shop", I am getting all three records like (1.kumar shop, 2. kumar KMPshop, 3.kumar MOAshop).

    Kindly help me out in resolving this issue.

    Thanks,
    Kumar N
  • KumarKumar Posts: 10Questions: 0Answers: 0
    oTable.fnFilter("^"+shopName+"$",1,true);

    where shopName is dynamically
    if shopName has ("kumar shop", "kumar KMPshop" , "kumar MOAshop")

    if I filter based on "kumar shop", I am getting all three records like ("kumar shop", "kumar KMPshop" , "kumar MOAshop").

    Kindly help me out in resolving this issue.

    Thanks,
    Kumar N
  • koosvdkolkkoosvdkolk Posts: 169Questions: 0Answers: 0
    edited April 2012
    I made an online example, and can reproduce the error on GC

    http://live.datatables.net/ujibug/7/edit

    (P.s. should the regex not contain \s for whitespace?)
  • KumarKumar Posts: 10Questions: 0Answers: 0
    Shop
    Profit ($)




    kumar (shop)1000


    kumar (slpshop)2000


    kumar warshop3000


    kumar kkpshop4000





    Made above change and try to filter "kumar (shop)", It wont work.

    Checked in ur live example.

    Please let me know the solution for this.

    Thanks,
    Kumar N
This discussion has been closed.