Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sudarshan Bhattacharjee on Jun 15, 2009 03:59
open dhtmlx forum
Filtering the grid for exact match

Hi

I'm using filterBy() method to filter out records in my grid.
Here is the scenario:
I have three links {All, Active, Inactive} outside the grid.
In the grid I have column containing value {Active, Inactive}
Now when I click the {Inactive} link all the rows for the column {Inactive} are displayed, but when I clicked {Active} link, the grid should display me only row for which the column has value as {Active}, instead it shows me all the rows with {Active, Inactive} values.
I found out that the filterBy() method does not make an exact search of the column value.

So how can I filter the grid for exact matches only.
Also I would like to know, once I have filtered a {Active/Inactive} records in grid, how can I remove the filter, which would be required when I'll click the {All} link, it should display me all the records.

Any help would be appreciated.

Thanks


Answer posted by Support on Jun 15, 2009 05:20
Instead of providing fixed value, for filtering, you can provide filtering method, which can define exact rules of filtering

Instead of 
 grid.filterBy(1,value)

you can use
 grid.filterBy(1,function(v){
      if (value=="") return true;
      return v == value; //exact match
 })

>> how can I remove the filter
Just filter by empty value
        grid.filterBy(0,"");