jQWidgets Forums

jQuery UI Widgets Forums Grid Filtering issues when mixing addfilter and filter row

This topic contains 7 replies, has 2 voices, and was last updated by  Peter Stoev 11 years, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author

  • gediminas
    Member

    Hello again.

    I have a grid which uses both filter row filtering and filters applied via the addfilter method.
    The situation is that I first add a filter via addfilter. Then I use the filter row on one field. Then I remove the firstly added filter via removefilter. Then I use the filter row again (on the same column, or another – doesn’t matter). And the grid applies the previously removed filter again.
    I am using server side data with server side filtering and pagination. jqWidgets 2.9.2, jQuery 1.9.1, Google Chrome.
    Code to add filter:
    var filtergroup = new $.jqx.filter();
    var filter = filtergroup.createfilter(“stringfilter”, filterValue, “starts_with”);
    filtergroup.addfilter(1, filter);
    this.gridElement.jqxGrid(‘addfilter’, “package_number”, filtergroup);
    this.gridElement.jqxGrid(‘applyfilters’);

    Code to remove the filter:
    this.gridElement.jqxGrid(“removefilter”, “package_number”);
    this.gridElement.jqxGrid(‘applyfilters’);

    This is not a server side issue as the requests sent from the grid are wrong.


    Peter Stoev
    Keymaster

    Hi,

    If you make Ajax requests, you should not expect that your code lines will run synchronous, too. When you call “removefilter”, you should expect a server call in case you’ve added the source object’s filter callback function that makes “updatebounddata” invokation. However, you may then edit the filter field which will result in another async server call. I don’t know which one of the server calls will end first and which one of your filters will be applied. The Grid will make calls based only on the parameters that you set.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    gediminas
    Member

    It seems I did not express myself clearly.
    I have a grid which has a filter row and next to the grid there is a text input box. Hitting enter on the input box trigers the code I posted earlier (addfilter if the length of the text entered is greater than 0 and removefilter if the length is 0).
    What the user does is:
    – use the input box to enter a value and hits enter (triggers addfilter and applyfilters, grid makes request to server [Req. 1])
    – when the grid binding is complete, enter a filter into the filter row on one of the grid columns (grid makes request to server [Req. 2])
    – when the binding is complete, clear the input text box and hit enter (triggers removefilter and applyfilters, grid makes request to server [Req. 3])
    – when binding completes enters a new value into the filter row. This is where grid makes a request to the server [Req. 4], but the request contains the filter from the input box which has already been removed.

    Req. 1
    filterscount:1
    groupscount:0
    pagenum:0
    pagesize:20
    recordstartindex:0
    recordendindex:15.793103448275861
    package_numberoperator:and
    filtervalue0:123
    filtercondition0:STARTS_WITH
    filteroperator0:1
    filterdatafield0:package_number

    Req. 2
    filterscount:2
    groupscount:0
    pagenum:0
    pagesize:20
    recordstartindex:0
    recordendindex:15.793103448275861
    package_numberoperator:and
    filtervalue0:123
    filtercondition0:STARTS_WITH
    filteroperator0:1
    filterdatafield0:package_number
    numberoperator:and
    filtervalue1:111
    filtercondition1:STARTS_WITH
    filteroperator1:1
    filterdatafield1:number

    Req. 3
    filterscount:1
    groupscount:0
    pagenum:0
    pagesize:20
    recordstartindex:0
    recordendindex:15.793103448275861
    package_numberoperator:and
    filtervalue0:111
    filtercondition0:STARTS_WITH
    filteroperator0:1
    filterdatafield0:number
    numberoperator:and
    filtervalue1:111
    filtercondition1:STARTS_WITH
    filteroperator1:1
    filterdatafield1:number

    Req. 4
    filterscount:2 <– this should be 1
    groupscount:0
    pagenum:0
    pagesize:20
    recordstartindex:0
    recordendindex:15.793103448275861
    package_numberoperator:and
    filtervalue0:1111
    filtercondition0:STARTS_WITH
    filteroperator0:1
    filterdatafield0:number
    numberoperator:and
    filtervalue1:123 <– this should not be here
    filtercondition1:STARTS_WITH
    filteroperator1:1
    filterdatafield1:package_number


    Peter Stoev
    Keymaster

    Hi,

    Hitting “Enter” on the Input box will trigger the Grid’s built-in code, too. So if you have bound to the “keydown” event of the input, you will mess up the built-in logic. It is also not applicable to have more than 1 filter per column when filter row is enabled. We will test your scenario and will investigate whether we have or not an issue about that behavior.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    gediminas
    Member

    It shouldn’t trigger an event since the text box is a totally different element. It is not created by the grid, nor by jqWidgets – I do it myself.
    I tried it out without hitting enter – only with a keyup event and I still get the same results.


    Peter Stoev
    Keymaster

    Hi,

    I prepared a sample and tested your scenario and confirm the odd behavior with the parameters. As a workaround, you may use the dataAdapter’s formatData callback and manually define the filtering parameters in the formatData function’s JSON data object. You may get the applied filters by using the Grid’s getfilterinformation method.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    gediminas
    Member

    Hello!
    Any info on when this is gonna be fixed?
    getfilterinformation returns the false filter data as well.


    Peter Stoev
    Keymaster

    Hi gediminas,

    You may use the workaround which I suggested you in the previous post. There is a work item about the reported behavior which will be fixed in some future version. If the issue is resolved, it will be included in the Release History available on the Documentation page.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.