jQWidgets Forums

jQuery UI Widgets Forums Grid clearfilters with asp.net webservice

This topic contains 6 replies, has 3 voices, and was last updated by  DM 12 years, 2 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • clearfilters with asp.net webservice #16599

    onefortypoint6
    Participant

    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
    }
    clearfilters with asp.net webservice #16602

    onefortypoint6
    Participant
    var removeAllFilters = function () {
    var filtersinfo = $('#jqxgrid').jqxGrid('getfilterinformation');
    $.each(filtersinfo,
    function (filter, filtercolumn, filtercolumntext) {
    $('#jqxgrid').jqxGrid('removefilter', filtercolumn.filtercolumn);
    }
    );
    }
    clearfilters with asp.net webservice #16604

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    clearfilters with asp.net webservice #16609

    onefortypoint6
    Participant

    Hi 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

    clearfilters with asp.net webservice #16613

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    clearfilters with asp.net webservice #16703

    onefortypoint6
    Participant

    Thanks Peter, will try the false parameter

    clearfilters with asp.net webservice #19053

    DM
    Participant

    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.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.