Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / How to reset filtering for a Grid using the api and igGridFiltering

How to reset filtering for a Grid using the api and igGridFiltering

New Discussion
S R
S R asked on Sep 29, 2014 3:12 PM

Dearest, 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!

Sign In to post a reply

Replies

  • 0
    Michael Peterson
    Michael Peterson answered on Sep 23, 2014 4:53 PM

    Hello,

    Thank you for contacting Infragistics!

    You can achieve this by calling the filter method and passing in an empty array for the filter expressions:

    https://www.igniteui.com/help/api/2014.1/ui.iggridfiltering#methods:filter

    • 0
      S R
      S R answered on Sep 23, 2014 6:17 PM

      Hello Mike, I wish it was that simple. I been experimenting with this setting: $("#mRecordsTable").igGridFiltering( "filter", [], false );

      The issue I have is that, when calling this line of code, even with the updateUI set to false, a webApi call gets launched in the back, one without filter.
      Then after that, I use the following code to set the new filter: $("#mRecordsTable").igGridFiltering("filter", ([{ fieldName: 'IsSolved', expr: true, cond: 'equals'}]));
      This immediately triggers a second apiWeb WITH parameter this time to be called.

      In the hope to make it even cleare for you, this is an overview of the web-api calls that I can see in fiddler:

      Initial .igGrid initialisation with datasource filter:

      • /api/mrecordapi/avalidID?%24orderby=Grouping+asc&%24filter=IsSolved+eq+false&%24skip=0&%24top=10&%24inlinecount=allpages

      resetting the filter + setting the new filter as described above (2calls):

      • /api/mrecordapi/avalidID?%24orderby=Grouping+asc&%24skip=0&%24top=10&%24inlinecount=allpages
      • /api/mrecordapi/avalidID?%24orderby=Grouping+asc&%24filter=IsSolved+eq+true&%24skip=0&%24top=10&%24inlinecount=allpages

      After this, sometimes the api call without filter gets shows or the one with the new filter gets shown, which results in very confusing behaviour.

      Is this a known bug ? Do I need to configure more settings to avoid this behaviour ? Is there a workaround?!

      Would realy appreciate if you could help me out with this one, I've been looking for a solution quite some time now.
      Thanks

      • 0
        Michael Peterson
        Michael Peterson answered on Sep 24, 2014 3:17 PM

        Hello,

        Thank you for the update. Since you are using remote data when you filter your service sends down a subset of the data that are within the filter condition. To get back to where you can filter all the data the service has to send down that data again, this is the reason for another post.

      • 0
        Michael Peterson
        Michael Peterson answered on Sep 29, 2014 3:12 PM

        Hello,

        I am following up to see if the information provided has resolved this matter.

        Please let me know if I may be of further assistance with this matter.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
S R
Favorites
0
Replies
4
Created On
Sep 29, 2014
Last Post
12 years ago

Suggested Discussions

Created by

S R

Created on

Sep 29, 2014 3:12 PM

Last activity on

Feb 23, 2026 3:45 PM