1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    103
    Vote Rating
    0
    mike lebowski is on a distinguished road

      0  

    Default Search filter broke after move to beta

    Search filter broke after move to beta


    I had this function listening to key up on my search field. It worked just fine in PR3. Then I moved to b1 / b2 and it still works in one direction - i.e. if you type "b" it filters on "b" , if you add an "e" it filters on "be", if you add a "d" , it filters on "bed" as expected. But it no longer filters as letters are removed. If I remove the "d" , it used to reset the filter to "be" and the list would update. Now it only works in the "add letter" direction. As I subtract letters from the sort string, it no longer works as expected. From what I can tell with diagnostic traces, the data set is narrowing with each additional character added to the sort, and never "widening". i.e. my regular expression test is only being applied to an ever decreasing number of records.

    So as I remove characters, the filter is being applied only to the number of records in the "current" set. Once the current set gets narrows 0, it never widens again. I can only assume that previously, the filter was being applied ALWAYS to the ENTIRE data set.

    Now, I suppose I CAN work around this, but I am wondering am I SUPPOSED to work around this. It is clearly a big difference in effect from PR3 to beta. And I looked in release notes and do not see this change as intentional. So is this a regression bug? Or is this new functionality as designed?


    Code:
    	doSearchFilter: function(field, e, eOpts){
            q = field.getValue();
            this.getSearchList().getStore().filterBy(function(record, id){
               var re = new RegExp('^' + q, "i");
               if(record.get('symbol').search(re) != -1 || record.get('company').search(re) != -1) {
                         return true;
                }
               return false;
    		});        
    	},

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    853
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    But q is being updated to the value?

    I wonder if filterBy is filtering on the data and not clearing the filter state.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    103
    Vote Rating
    0
    mike lebowski is on a distinguished road

      0  

    Default


    q is clearly getting the new value. I have tracing at every line that I removed for readability.

    q = "b", then "be", then "bed", then "be" , then "b" etc depending on whether I am adding or subtracting chars.
    What I observe is that the number of RECORDS that the regexp is being banged against is the number or records currently being displayed based on the previous doSearchFilter call , not the total number or records in the store.

    So initially, assume number of records in strore is 1000.
    I type 'b' - q = 'b' the regexp is banged against the entire number of records in the store. Say 200 match.
    I type 'e' - q = 'be' the rexexp is banged agains the 200 (not the full 1000), and say 30 match
    I type 'd' - q= 'bed' , regexp is banged against the 30, say none match , my list is blank now.
    I backspace , 'q = 'be' regexp is banged against zero records , my list remains blank instead of showing the 30 expected matches.
    etc

    you follow?

  4. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    103
    Vote Rating
    0
    mike lebowski is on a distinguished road

      0  

    Default


    I have worked around this by putting a clearFilter() call prior to the filterBy() call. But I really would like to know if that is what I am supposed to do or whether that is just working around a bug?

    Fwiw, the filter seems quite slow on a large data set. It seems slower with this clearFilter workaround than it did in PR3 , when I did not need the clearFilter workaround.

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    Hey Mike,

    This might actually be a bug. I'll make sure it gets moved to the bug forum tomorrow and will also take a look into the potential performance problem you mentioned.

    Thanks

  6. #6
    Sencha User
    Join Date
    Dec 2011
    Posts
    103
    Vote Rating
    0
    mike lebowski is on a distinguished road

      0  

    Default


    Hi Tommy,

    It might be working as designed. I can see that there are some benefits in performance when one is adding characters to the search string ...i.e. further narrowing ... as the query is working on a progressively smaller set, it will be faster in that direction.

    Of course, it does not work at all without my workaround when one is expanding the search by removing characters from the search string. But maybe that is expected by sencha engineers.

    anyway, I am interested in learning what is the intended effect. thanks.

Thread Participants: 2