1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    Gucky is on a distinguished road

      0  

    Default Unanswered: Grid filter race condition

    Unanswered: Grid filter race condition


    When using the Grid Filter Feature, a query that is executed by the server may take about 10 seconds. Now it the user is typing a value into the filter field and waits more than the defined 500 milliseconds, before typing the next character, a second request will be send to the server, and again the user is slow in typing another one so we now have three request that have been send and will return in any order. Is there a way to ignore the first two and just take the last requests data? In my case as the last is the fastest, the data are returned only to be overwritten by the previous request that finally return a bit later. Any suggestions?

  2. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    Is it the filter in the ux?

    I see there the follwing method onStateChange,
    mayby override it and do a check if the filter contains at least two characters before fire an filterupdate.

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    Gucky is on a distinguished road

      0  

    Default minimum keystrokes

    minimum keystrokes


    Yes, its in ux, I could add that, but I need at least four to overcome the race condition, unfortunately I do need the ability to search from the first character onward.

  4. #4
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    Why is it needed to send the first characters to the server? The requests are made in the reload function

    Code:
    reload : function () {
            var me = this,
                store = me.view.getStore();
    
            if (me.local) {
                store.clearFilter(true);
                store.filterBy(me.getRecordFilter());
                store.sort();
            } else {
                me.deferredUpdate.cancel();
                if (store.buffered) {
                    store.pageMap.clear();
                }
                store.loadPage(1);
            }
        }
    Isn't it possible to condition that function that only three or four characters should be types before executing a reload?

  5. #5
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    Gucky is on a distinguished road

      0  

    Default Reload

    Reload


    The problem is that the underlying table contains about 30000 records, the user needs to be able to get records starting with e.g. A or B and once displayed tighten the filter, Others may know the first 5 characters and will, as you suggest get a smaller list. But I am not able to enforce this. So ideally, the store should simply discard a request that is older than the one it already received. Hope this makes sense.

  6. #6
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    Well logically,

    I think you should block a reload (clienside) if one is standing out. So disable mulitple loads, when one has not returned yet. You can put a listener on the store's load event to check when its finished. To check if the store is loading you can check isLoading function.

    Meanwhile during that load you keep registering keystrokes, collect them, when the first load returns/stops you start executing the next filter request.


    For that you need to modify the reload function of the filter plugin.

  7. #7
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    Gucky is on a distinguished road

      0  

    Default Overwrite Filter / Change Store behaviour

    Overwrite Filter / Change Store behaviour


    I could do that, or it may be simpler to just fire on the Enter key rather than after each keystroke.

    I still think that a feature , maybe for the store rather than the filter, to either
    - only allow sequential calls therefore blocking any requests until the store is loaded
    - have an option to discard an existing load is a new request comes in
    would be useful.

Thread Participants: 1

Tags for this Thread