Hello,
I have a layout with a toolbar and grid attached to it. I have an input box “input_search” that I’d like to use to filter my grid results.
I’ve tried grid1.getFilterElement("input_search")._filter = function(){
var input = this.value;//get text of input
return function(value, id){
for(var i=0;i<grid1.getColumnsNum();i++){ //iterate through columns
var val=grid1.cells(id,i).getValue() //gets value of current cell
if (val.toLowerCase().indexOf(input.toLowerCase())!==-1){
return true
}
}
return false
}
}
but I get an error that grid1.getFilterElement(…) is undefined.
Any help getting this to work would be appreciated.
Thanks!
Unfortunately the getFilterElement() method works only with the in-header filters.
Please, try to use the following solution:
toolbar = new dhtmlXToolbarObject("toolbarObj");
toolbar.addInput("input_search",0,"",100);
inp = toolbar.getInput("input_search");
inp.onkeyup = function(){
grid.filterBy(1,inp.value);
};
This code spits out an error when I use it: “this.filterTreeBy is not a function”, dhtmlxgrid_filter.js line 7.
Also, will that code search all the columns of the grid?
Thanks for you help on this!
The provided code works well for us.
If any issue still occurs - please, provide us with any kind of sample of your code.
Also, will that code search all the columns of the grid?
No. You can see that it is a simple filterBy() method. It filters on one column only.
How to search all fields, my datas are loaded from cache, using dhtmlxgrid?
Could you please, clarify the using case.
Filtering applies to all the data loaded to the grid.