Search code examples
dhtmlx

How to call multiple filters in DHTMLX Grid


I would like to call multiple functions in DHTMLX Grid.

I have a table which has the following 7 columns

EX:

---------------------------------------------------------------
No. | Name | Age | Gender | Marital Status | Education | City |
---------------------------------------------------------------

I would like this grid to be filtered by multiple filter conditions. For Ex: Filter the grid to have only the gender 'Male' whose age is below 35.

Currently my doFilter() function looks like this.

function doFilter() {
   mygrid.filterBy(3,'M',true);
   mygrid.filterBy(2,function(a){ return (a > 55);} );
}

But the grid is only filtered by age not by Gender column.

Please let me know how to apply multiple filter condition in DHTMLX Grid.


Solution

  • You need to use it as

    mygrid.filterBy(3,'M');
    mygrid.filterBy(2,function(a){ return (a > 55);}, true);
    

    second filterBy call must have true as last parameter, to preserve results of previous filterBy call.