0
votes

Who knows how to filter the Store right?

I tried to do it in listener of leafItemTap of Nested List, but my leaf items not tapping now. Massage in console: "Uncaught TypeError: Cannot call method 'filter' of undefined "

Here is Nested list, where Store must be filtered:

Ext.define('Application.view.SplitView', {
extend: 'Ext.Container',
xtype: 'splitview',    
config: {
    layout: 'card', 
    store: null
},

initialize: function() {        
    this.nestedList = Ext.create('Ext.NestedList', {
        title : 'Рецепты',
        detailCard: Ext.create('Application.view.MainDetail'),      
        store: this.getStore(),            
        listeners: {
            scope: this,
            leafitemtap: this.onLeafItemTap
        }
    });

    this.setItems([this.nestedList]);
},    
updateStore: function(newStore) {
    if (this.nestedList) {
        this.nestedList.setStore(newStore);
    }
},
onLeafItemTap: function(nestedList, list, index, node, record, e) {
    var psn = record.get('text');
    console.log(psn);
    var detailCard = nestedList.getDetailCard();
    var store = Ext.getStore('Application.store.DetailStore');        
    store.filter('title', 'Brownies');
    console.log(store);
}

});

This is my Store, which I want to filter:

Ext.define('Application.store.DetailStore', {
extend: 'Ext.data.Store',

config: {
    model: 'Application.model.DetailModel',
    autoLoad :true,
    sorters: 'title',
    grouper : function(record) {
        return record.get('title')[0];
        },

   proxy: {
    type: 'ajax',
    url : '/data/data1.php',
   reader: {
   type: 'json',
  rootProperty:'recipes'}
         } 
}

});

And Store's model:

Ext.define('Application.model.DetailModel', {
extend: 'Ext.data.Model',
config: {
    fields: [       
    {name: 'title',  type: 'string'},
    {name: 'serves',  type: 'string'},
    {name: 'cooktime',  type: 'string'},
    {name: 'ingridients',  type: 'string'},
    {name: 'picture',  type: 'string'},
    {name: 'kitchen',  type: 'string'},
    {name: 'category',  type: 'string'},
    {name: 'instructions',  type: 'string'}         
]
},

fullName: function() {
    var d = this.data,
    names = [
        d.title         
            ];
    return names.join(" ");
}

});

I'm new in Sencha and every advice will be useful

1
What do you get when you do console.log(store); before filtering ?Titouan de Bailleul
It returns "undefined", I was wrong in getting Store?Ellina Cherevkova

1 Answers

0
votes

The following error means the object which you're calling the filter function on is undefined

"Uncaught TypeError: Cannot call method 'filter' of undefined "

In your case, the store is undefined.

Try to get it by doing :

var store = Ext.getStore('DetailStore');

Also, you could check what stores are in the StoreManager by doing :

console.log(Ext.data.StoreManager.all);

Hope this helps