How to reset filtering for a Grid using the api and igGridFiltering
New DiscussionDearest, I have a igGrid that i bind to Web Api. As you can see, I set an initial filtering on a column called IsSolved.
I am not using the UI to change the filtering but want to use the API and change the filter for this column manually.
that._dataSource = new $.ig.JSONPDataSource({
type: ‘remoteUrl’,
dataSource: apiUrl,
responseDataKey: ‘Items’,
responseTotalRecCountKey: ‘Count’,
filtering: {
expressions: [{ fieldName: “IsSolved”, expr: false, cond: “equals” }]
}
});
A user can choose ‘true’, ‘false’, ‘both’ for the IsSolved from a dropdownlist , and I set the filter like this in the change event:
$(‘#solvedStatusFilter’).change(function () {
if (selectedStatusFilter == MRecordStatusFilter.Solved)
$(“#mRecordsTable”).igGridFiltering(“filter”, ([{ fieldName: ‘IsSolved’, expr: true, cond: ‘equals’}]));
else if (selectedStatusFilter == MRecordStatusFilter.Unsolved)
$(“#mRecordsTable”).igGridFiltering(“filter”, ([{ fieldName: ‘IsSolved’, expr: false, cond: ‘equals’}]));
This all happens clientSide.
The problem I’m having now is that when I select a second option, the new filter condition gets APPENDED (with and), which doesn’t give me the correct result ofcourse.
I would like to override the filter instead of appending a new one.
I’ve already been playing around with clearing all the filters before adding the new filter I want but didn’t get it to work either, I used $(“#mRecordsTable”).igGridFiltering(“filter”, [], false); but that immediately fires a call to the webApi which is not what I want at all.
So please, How can I remove all the filters on a column/igGrid before apllying a new one AND without triggering a WebApi call before the new filter expression is set? I would be very thankful!