0

ストアを正しくフィルタリングする方法を誰が知っていますか?

ネストされたリストのleafItemTapのリスナーでそれを実行しようとしましたが、リーフアイテムがタップしません。コンソールでのマッサージ: "Uncaught TypeError:Undefinedのメソッド'filter'を呼び出せません"

これがネストされたリストで、ストアをフィルタリングする必要があります。

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

});

そしてストアのモデル:

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

});

私は煎茶が初めてで、すべてのアドバイスが役に立ちます

4

1 に答える 1

0

次のエラーは、関数を呼び出しているオブジェクトfilterが未定義であることを意味します

"Uncaught TypeError:undefinedのメソッド'filter'を呼び出すことができません"

あなたの場合、ストアは未定義です。

やってみてください:

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

また、次の手順を実行して、StoreManagerにあるストアを確認できます。

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

お役に立てれば

于 2012-06-23T17:04:09.730 に答える