XGrid methods used to filter multiple columns mathcing with

I have below requirement



When the user enters partial search string into this textbox, and hits enter, an AJAX dropdown is shown with a list of suggested names.



When the user selects one of the names from the AJAX dropdown, the grid table should be filtered on two columns, both the column1 and column2.



For example, suppose the award table contains the following four awards.



Column1: John Doe, Column2: Jane Schmoe

Column1: John Doe, Column2: Jennifer Foo

Column1: James Bar, Column2: John Doe

Column1: James Bar, Column2: Jane Schmoe



If the user enters and selects “John Doe” into the AJAX textbox, the table should shown as below:



Column1: John Doe, Column2: Jane Schmoe

Column1: John Doe, Column2: Jennifer Foo

Column1: James Bar, Column2: John Doe



If the user enters and selects “Jane Schmoe” into the AJAX textbox, the table should show



Column1: John Doe, Column2: Jane Schmoe

Column1: James Bar, Column2: Jane Schmoe



I tried with the below ,but this seems works for only the last column method call below (mygrid.filterBy(col2,selectedValue,true)).



mygrid.filterBy(col1,selectedValue);

mygrid.filterBy(col2,selectedValue,true);



Please suggest me how to approach this issue…



Regards,

Narayan Dhumale

Try to use following algorithm:
var val=“John Doe”;
mygrid.filterBy(0,function(value,id){
if (mygrid.cells(id,0).getValue().toLowerCase().indexOf(val)!=-1) return true;
if (mygrid.cells(id,1).getValue().toLowerCase().indexOf(val)!=-1) return true;
return false;
});


Thanks for your reply.



 



I have tried the option, but no luck.Could you please suggest me any alternate where i can filter on more than one column with a single search keyword at once.

Please check example at the attachment
sample_complex_filter.zip (86 KB)


Thanks team!



This is wroking fine now…! :slight_smile:

This works with the Smart Rendering Grid too! - Thanks DHTMLX Team.