Grid - Clear All Filters

Is there an easy way to clear all the filters which have been added via the header filters (including the inputs)?

I know that grid.filterBy(0,"") will clear all the actual filters, but this leaves all the inputs and comboboxes in the header still populated.



Thanks,

- Dave


There is no API for such task, but can be done directly through HTML as


var inps = this.hdr.getElementsByTagName(“INPUT”);
for (var i=0; i<inps.length; i++) inps[i].value="";
var inps = this.hdr.getElementsByTagName(“SELECT”);
for (var i=0; i<inps.length; i++) inps[i].value="";



That would find a lot of extra elements on the page, if there are any. After going over the library for filters, we came up with the following addiiton:



dhtmlXGridObject.prototype.clearFilters=function(){for (var i=0;i<this.filters.length;i++){switch(this.filters[i][0].tagName.toLowerCase()){case “input”:this.filters[i][0].value="";break;case “select”:this.filters[i][0].selectedIndex=0;break;case “div”:this.filters[i][0].combo.setComboValue("");break}}this.filterByAll()};



That seems to work for us; hopefully it can be added to future versions if you find it usefull.



Thanks,



- Dave

That would find a lot of extra elements on the page, if there are any
Actually not, it will find all inputs inside header which most probably are filters only

>>That seems to work for us; hopefully it can be added to future versions if you find it usefull.
We have missed API for such use-case initially, but it seems a pretty useful so method with similar functionality will be added to the next build of dhtmlxgrid.


>> Actually not, it will find all inputs inside header which most probably are filters only



Riiiight. Missed that bit when I looked at the code. :wink:



>> We have missed API for such use-case initially, but it seems a pretty useful so method with similar functionality will be added to the next build of dhtmlxgrid.



Great! Thanks again!