jQWidgets Forums
jQuery UI Widgets › Forums › Grid › clearfilters with asp.net webservice
Tagged: grid remove filters
This topic contains 6 replies, has 3 voices, and was last updated by DM 12 years, 2 months ago.
-
Author
-
Hi, in case anyone is doing this, if you are trying to apply a filter to the grid via an asp.net web service, the clearfilters method will prevent you adding a new filter. The work around is to loop through any filters set, and remove them 1 at a time.
For example:
(this doesnt’ work, it clears all filters, even the new one you added)var applySearchButtonsFilter = function (buttonName) {
$("#jqxgrid").jqxGrid('clearfilters');
…then addfilter code here
}(this does work, manually removing the filters)
var applySearchButtonsFilter = function (buttonName) {
//$("#jqxgrid").jqxGrid('clearfilters');
var filtersinfo = $('#jqxgrid').jqxGrid('getfilterinformation');
$.each(filtersinfo,
function (filter,filtercolumn,filtercolumntext) {
$('#jqxgrid').jqxGrid('removefilter', filtercolumn.filtercolumn);
}
);
...then addfilter code here
}
var removeAllFilters = function () { var filtersinfo = $('#jqxgrid').jqxGrid('getfilterinformation'); $.each(filtersinfo, function (filter, filtercolumn, filtercolumntext) { $('#jqxgrid').jqxGrid('removefilter', filtercolumn.filtercolumn); } ); }
Hi onefortypoint6,
The “clearfilters” method removes all filters and works as expected. You can use it and add filters after that, too. A demonstration is available online – filtering.htm.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter, when I use “clearfilters” it does clear all of the filters, but when I add a new filter in the same function, the newly added filters are not passed to my web service. It’s okay, it is working great with the manual removal of entries. Love the product though, great work
Hi onefortypoint6,
The “clearfilters” method clears the filters and refreshes the Grid. If you do async server filtering and you try to add a new filter while the filters are cleared, I suppose that you will end with 2 async requests to your server. As it is async operation, it is possible that the “clear” operation is the last one in the stack and the request with your new filter is not taken into account. If you just want to clear the filters without refreshing the Grid, call the “clearfilters” with parameter false.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks Peter, will try the false parameter
I hit this problem also but specifying the false parameter didn’t work. Tracing through the code I found the condition:
if (apply == true || apply != undefined) {
this.applyfilters();
}where “apply” is the “false” argument specified in the ‘clearfilters’ call. If “apply” is false then it’s not undefined and it applies the filters anyway.
I’ve worked round the problem it by passing “undefined”. i.e.
$(‘#jqGrid’).jqxGrid(‘clearfilters’, undefined);
and then forcing a refresh on the grid data afterwards.
-
AuthorPosts
You must be logged in to reply to this topic.