如何过滤商店?

时间:2012-06-23 16:32:02

标签: sencha-touch extjs sencha-touch-2

谁知道如何过滤商店?

我尝试在嵌套列表的leafItemTap的监听器中执行此操作,但我的叶子项目现在没有点击。在控制台中按摩:“未捕获的TypeError:无法调用未定义的方法'过滤器'

以下是嵌套列表,其中必须过滤Store:

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);
}

});

这是我想要过滤的商店:

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'}
         } 
}

});

和Store的模特:

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(" ");
}

});

我是Sencha的新手,每个建议都很有用

1 个答案:

答案 0 :(得分:0)

以下错误表示您正在调用filter函数的对象未定义

  

“未捕获的TypeError:无法调用未定义的方法'过滤器'”

在您的情况下,商店未定义。

尝试做到:

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

此外,您可以通过执行以下操作来检查StoreManager中的商店:

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

希望这有帮助