extjssencha-architect

How to use FilterBy Method in Extjs local store


Im new to Extjs 7.6 and using Sencha Architect. I changed a remote filtered store to a local store.

How do i use the filterBy function in my controller? I have read some examples but dont really understand.

The value is given by an input field.

Following my remote filter method:

application.getStore('ServiceStore').filter(
     [{id: 'number', property: 'number', value: value, operator: 'LIKE', andor:'OR'},
     {id: 'description', property: 'description', value: value, operator: 'LIKE', andor:'OR'}]
);

How to translate this to a local filterBy method?


Solution

  • I have found the answer:

    store = application.getStore('ServiceStore');
    store.filter(new Ext.util.Filter({
        filterFn: function(item) {
            if (item.data.number.indexOf(value) > -1 || item.data.description.indexOf(value) > -1) {
                return true;
            } else {
                return false;
            }
        }
    }));