ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: gammax500 on October 01, 2015, 10:16:05 pm

Title: Clear Filters in Grid
Post by: gammax500 on October 01, 2015, 10:16:05 pm
I searched in the forums for how to clear added grid filters and found only one old post about this http://paramquery.com/forum/index.php?topic=519.msg3184;topicseen#msg3184 (http://paramquery.com/forum/index.php?topic=519.msg3184;topicseen#msg3184), where the solution was to add $grid.pqGrid( "filter", { oper:'replace', data: [] } ); to the click event for the toolbar button.

That works to clear the filters from the grid and restore the data, however it leaves the text typed into the filter text fields.  How do I clear out this text?

toolbar:

{ type: 'button', label: 'Clear Filters', listeners: [
     {
      "click": function (evt, ui) {

          $grid.pqGrid( "filter", { oper:'replace', data: [] } );

       }
 }
]
},
Title: Re: Clear Filters in Grid
Post by: paramvir on October 02, 2015, 01:40:14 pm
Please use this code in the click event, where grid is the widget instance.
Code: [Select]
                        var CM = grid.getColModel();
                        for(var i=0, len = CM.length; i < len; i++){
                            var column = CM[i];
                            if(column.filter){
                                column.filter.value = null;
                                column.filter.cache = null;
                            }
                        }
                        grid.refreshHeader();
grid.filter({
oper: 'replace',
data: []
});
Title: Re: Clear Filters in Grid
Post by: gammax500 on October 06, 2015, 03:21:36 am
Thanks,

I tried the code block and it reset almost every filter, however one of my filters is a date range.  Your code cleared the first but not the second of the dates.
Title: Re: Clear Filters in Grid
Post by: paramvir on October 06, 2015, 08:04:32 am
Please add column.filter.value2 = null; beside column.filter.value = null;