Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Alice on Feb 12, 2009 09:44
open dhtmlx forum
:: DHX Grid :: Filter based on two column values

Hi there,

I want to filter the rows in the grid based on two column values.

I am doing following

First I run filterBy() API to filter rows based on one column value and then on those filtered rows, I will run another filterBy() API again to filter rows based on second column value.

If this is not possible, can we do this ?

onFilter or onFilterEnd event, we can hide rows not satisfying filter criteria ?

Can u help me on this please ?

Thanks!!!
Answer posted by dhxtSupport on Feb 13, 2009 05:59
Please see example at the attachment 
Attachments (1)
sample1.zip136.36 Kb
Answer posted by Alice on Feb 13, 2009 07:25
Hi,

I saw the example, but can you provide example for something like this ----> When I click on some button which is not in context of grid, I will run one filterBy(); based on that some rows will be filtered. Then try to filter some more rows searched from #text_filter present in the grid itself. Means suppose at load say there are 100 rows, then based on first filterBy() API called on click of the button, 25 rows got filtered[Remaining Rows: 75], now out of 75 rows, I want to filter again more rows based on #text_filter. How to do this ?
Answer posted by dhxtSupport on Feb 13, 2009 09:45

To create filter outside the grid:

<input onkeyup="filterByAuthor()" id="author_flt" />

function filterByAuthor(){
  var aVal = document.getElementById("author_flt").value.toLowerCase();
  mygrid.filterBy(2,aVal);
  }


Answer posted by Support on Feb 13, 2009 09:51

By default #text_filter run against all rows in grid, but you can inject additional rules through onFilterStart event

grid.attachEvent("onFilterStart",function(){
        b.push(2);
        a.push( document.getElementById("author_flt").value );
        this.filterBy(b,a);
        return false;
})


as result, each time when text filter triggered - it will filter grid not only by own value, but include value of external filter as well 

>>I will run another filterBy() API again to filter rows based on second column value.
Technically yes, third parameter of filterBy says is filtering need to be done on full dataset ( false ) or already filtered dataset ( true ) - it can be used if you filter data only by filterBy calls.