【问题标题】:How to filter the Store?如何过滤商店?
【发布时间】:2012-06-25 15:16:51
【问题描述】:

谁知道如何正确过滤商店?

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

这里是嵌套列表,必须过滤 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 的新手,每个建议都会很有用

【问题讨论】:

  • 过滤前console.log(store);会得到什么?
  • 返回“undefined”,我获取Store有错吗?

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


【解决方案1】:

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

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

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

尝试通过做得到它:

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

此外,您可以通过以下方式检查 StoreManager 中的商店:

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

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 2015-07-30
    • 2015-12-28
    相关资源
    最近更新 更多