Results 1 to 2 of 2

Thread: hasMany association store filter. Bug?

  1. #1
    Sencha User
    Join Date
    Jun 2014
    Posts
    10
    Answers
    2

    Default hasMany association store filter. Bug?

    Hello!

    I have model with hasMany association (ExtJS 4.2.1.883):
    Code:
    Ext.define('App.model.Asset', {
        extend: 'Ext.data.Model',
    
        uses: [ ... ],
        fields: [ ... ],
    
        hasMany: [
            {
                name: 'devices',
                model: 'App.model.Device',
                foreignKey: 'assetId',
                primaryKey: 'id'
            }
        ]
    });
    After creating asset model automatically added filter to devices store:
    Code:
    exactMatch: true
    filter: undefined
    filterFn: undefined
    initialConfig: { ... }
    property: "assetId"
    root: "data"
    value: undefined
    Next, I need to add some filters to the store and filter it (for unsaved asset model), but I get an error:
    Code:
    Uncaught TypeError: Cannot read property 'call' of undefined
    into static method createFilterFn in Ext.util.Filter:
    Code:
    createFilterFn: function(filters) {
                return filters && filters.length ? function(candidate) {
                    var isMatch = true,
                        length = filters.length,
                        i, filter;
    
    
                    for (i = 0; isMatch && i < length; i++) {
                        filter = filters[i];
                        
                        if (!filter.disabled) {
                            isMatch = isMatch && filter.filterFn.call(filter.scope || filter, candidate);
                        }
                    }
                    return isMatch;
                } : function() {
                    return true;
                };
            }
    This is bug or am I doing something wrong?


    P.S. Now I just changed createFilterFn method:
    Code:
    if (!filter.disabled && filter.filterFn)

  2. #2

    Default Override it instead of

    you can override the class instead of hand edit
    Code:
    Ext.override('Ext.util.Filter',{
        statics:{
            createFilterFn: function(filters) {
                return filters && filters.length ? function(candidate) {
                    var isMatch = true,
                        length = filters.length,
                        i, filter;
                        
                    for (i = 0; isMatch && i < length; i++) {
                        filter = filters[i];
                        
                        if (!filter.disabled && filter.filterFn) {
                            isMatch = isMatch && filter.filterFn.call(filter.scope || filter, candidate);
                        }
                    }
                    return isMatch;
                } : function() {
                    return true;
                };
            }
        }
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •