Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by muhabbat ali on Apr 20, 2009 21:44
open dhtmlx forum
Complex Search in DHTMLX grid

Hi,
I m thankx full to u to give me right good solution of the last question.

Now I want to make a search / filtering in dhtmlxgrid using (OR,In) operators .

Default behaviour of the filter uses AND operator . but my user can use AND , OR , IN operators (All possible operator at runtime) .
What I should Do?

Is thers any demo / example from where I can get idea HOW TO DO IT?

Regards

MUHABBAT ALI
Answer posted by dhxSupport on Apr 21, 2009 01:54
Here is example how to use “OR” logic to filter grid by different columns:
var text = document.getElementById("someInputId").value;
grid.filterBy(0,customFilter);
function customFilter(value,id){
  if ( grid.cells(id,0).getValue().toString().toLowerCase().indexOf(text) != -1) return true;
  if ( grid.cells(id,1).getValue().toString().toLowerCase().indexOf(text) != -1) return true;
  if ( grid.cells(id,2).getValue().toString().toLowerCase().indexOf(text) != -1) return true;
  return false;
};

Inside the customFilter function you can check necessary input’s values and decide what should filter returns. By the way custom filter is fully depends on your business logic. If you need some special functionality from the dhtmlxGrid you can contact sales@dhtmlx.com and request customization of the component.