Categories | Question details Back To List | ||
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 Answer posted by Support on Jan 21, 2009 03:53 There is no API for such task, but can be done directly through HTML as var inps = this.hdr.getElementsByTagName("INPUT"); Answer posted by David Hutchings on Jan 21, 2009 13:42 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 Answer posted by Support on Jan 22, 2009 03:52 >>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. Answer posted by David Hutchings on Jan 22, 2009 12:59 >> 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. ;-) >> 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! |