Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-2926 in a recent build.
  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    7
    Vote Rating
    0
    alexd1971 is on a distinguished road

      0  

    Default Ext.data.Store.filter function works incorrectly

    Ext.data.Store.filter function works incorrectly


    REQUIRED INFORMATION
    Ext version tested:
    • Sencha Touch 2.0.1
    Browser versions tested against:
    • Safari 5.1.7
    Description:
    • Call of Ext.data.Store.filter function with array of filters creates incorrect filters
    Code:
    var store = Ext.getStore('SomeStore');
    store.filter([{property: 'someProperty', value: 'someValue'}]); //yelds incorrect filtering
    store.clearFilter();
    store.filter('someProperty', 'someValue'); //works correctly
    Steps to reproduce:
    • run included code
    The result was expected:
    • Item with id=1 in store.data.items
    The result that occurs instead:
    • No items in store
    Test case:
    Code:
    //Model definition
    Ext.define('Test.model.Test', {
        extend: 'Ext.data.Model',
         config: {
            fields: [
                {name: 'id', type: 'int'},
                {name: 'name', type: 'auto'},
                {name: 'email', type: 'auto'}
            ],
        }
    });
    
    var store = Ext.create('Ext.data.Store',{
          model: 'Test.model.Test',
          storeId: 'TestStore',
          data: [
               {"id": 0,"name": "test0","email": "test0@domain.com"},
               {"id": 1,"name": "test1","email": "test1@domain.com"}
          ]
    });
    
    /* Works incorrectly */
    store.filter([{property: 'id', value: 1}]); //yelds no items in store
    
    /* 
    //Works correctly 
    store.filter('id',1);
    
    //Also works correctly
    store.setFilters([{property: 'id', value: 1}]);
    store.filter();
    */
    Helpful information:
    • Works correctly in 2.0.0

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Vote Rating
    846
    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


    Thanks for the report!
    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
    Ext JS Premium Member
    Join Date
    Aug 2007
    Location
    Antwerp, Belgium
    Posts
    559
    Vote Rating
    29
    joeri has a spectacular aura about joeri has a spectacular aura about joeri has a spectacular aura about

      0  

    Default


    To bring back the old behavior:
    Code:
    // override 2.0.1 to allow applying multiple filters to a store
    Ext.define('Fix.Ext.data.Store', {
       override: 'Ext.data.Store',
       filter: function(property, value, anyMatch, caseSensitive) {
          var data = this.data,
          // JS: added Ext.isArray check here
            filter = property ? ((Ext.isFunction(property)||Ext.isArray(property)) ? property : {
                property     : property,
                value        : value,
                anyMatch     : anyMatch,
                caseSensitive: caseSensitive,
                // By setting the id we ensure there is only one filter active
                // at a time for this property.
                id           : property
             }) : null;
    
          if (this.getRemoteFilter()) {
             if (property) {
                if (Ext.isString(property)) {
                   data.addFilters(filter);
                }
                else if (Ext.isArray(property) || property.isFilter) {
                   data.addFilters(property);
                }
             }
          } else {
             data.filter(filter);
             this.fireEvent('filter', this, data, data.getFilters());
             this.fireEvent('refresh', this, data);
          }
       }
    });

  4. #4
    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


    Thank you for the report. This has been fixed for the next release.

  5. #5
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    14
    Vote Rating
    0
    shodan_uk is on a distinguished road

      0  

    Default


    Quote Originally Posted by joeri View Post
    To bring back the old behavior:
    Code:
    // override 2.0.1 to allow applying multiple filters to a store
    Ext.define('Fix.Ext.data.Store', {
       override: 'Ext.data.Store',
       filter: function(property, value, anyMatch, caseSensitive) {
          var data = this.data,
          // JS: added Ext.isArray check here
            filter = property ? ((Ext.isFunction(property)||Ext.isArray(property)) ? property : {
                property     : property,
                value        : value,
                anyMatch     : anyMatch,
                caseSensitive: caseSensitive,
                // By setting the id we ensure there is only one filter active
                // at a time for this property.
                id           : property
             }) : null;
    
          if (this.getRemoteFilter()) {
             if (property) {
                if (Ext.isString(property)) {
                   data.addFilters(filter);
                }
                else if (Ext.isArray(property) || property.isFilter) {
                   data.addFilters(property);
                }
             }
          } else {
             data.filter(filter);
             this.fireEvent('filter', this, data, data.getFilters());
             this.fireEvent('refresh', this, data);
          }
       }
    });
    This exactly what I need. How do I implement this? I've saved the above code in app/data/Store.js and altered 'Fix.Ext.data.Store' to match my apps namespacing. I've then extended this new class instead of Ext.data.Store, however, I'm now getting the following error:

    Code:
    Object #<Object> has no method 'getStore'
    Any ideas?

  6. #6
    Ext JS Premium Member
    Join Date
    Aug 2007
    Location
    Antwerp, Belgium
    Posts
    559
    Vote Rating
    29
    joeri has a spectacular aura about joeri has a spectacular aura about joeri has a spectacular aura about

      0  

    Default


    If you load the code then Ext.data.Store itself is patched. You don't need to change anything in your code. It can just keep pointing to Ext.data.Store (or any of its subclasses).

    You just need to make sure the code is loaded before your stores are created.

  7. #7
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    14
    Vote Rating
    0
    shodan_uk is on a distinguished road

      0  

    Default


    OK. Does the Fix namespace have any sort of special meaning?

  8. #8
    Ext JS Premium Member
    Join Date
    Aug 2007
    Location
    Antwerp, Belgium
    Posts
    559
    Vote Rating
    29
    joeri has a spectacular aura about joeri has a spectacular aura about joeri has a spectacular aura about

      0  

    Default


    No, I'm just using that convention to identify the overrides that fix bugs. I don't know if there's a standard practice for namespacing overrides.

  9. #9
    Sencha User
    Join Date
    Apr 2013
    Posts
    9
    Vote Rating
    0
    5LiC is on a distinguished road

      0  

    Default


    This is still a problem in sencha touch 2.1.1 but joeri's fix works wonderfully