3

コントローラーからロードされたストアを取得しようとすると、nullになります。ロードも成功しました。私はそれを確認しました。

私は次のような店を持っています。

Ext.define('GridApp.store.schemedatastore',{
    extend: 'Ext.data.Store',
    model: 'GridApp.model.schemedatamodel',
    autoLoad: true,
    alias: 'store.schemedata',
    storeId: 'schemedatastoreid',
    constructor:function(){
        console.log('Calling parent');
        this.callParent(arguments);
        },
    listeners: {
        load:function(store,records,isSuccessful){
            if(isSuccessful){
                console.log('Load successful');
            }
            console.log(records[0].get('name'));
            console.log('scheme Data store loaded too.');
        },
    }
});

私のコントローラーには、次のように追加しました。

stores: ['schemesstore',
             'schemedatastore'],

コントローラでこれらの両方の方法でアクセスしてみましたが、

Ext.getStore('schemedatastoreid');これはnullを返し this.getschemedatastoreStore();、コントローラーの未定義の関数であることを示します。

ここで何かが足りないのですか?

4

1 に答える 1

5

これらのいずれかを試してください:

this.getSchemedatastoreStore()

// the non-alias version of getStore    
Ext.StoreManager.lookup('schemedatastoreid') 

// in case MVC behavior overrides your storeId config
Ext.StoreManager.lookup('schemedatastore') 

MVCパターンでは、独自に定義しない場合、ストアにストアクラス名がストアIDとして自動的に付与されます。

したがって、構成を削除するstoreId: 'schemedatastoreid'と、storeIdは自動的に取得されますschemedatastore。私は通常、MVCストアに個別の構成を与えstoreIdないので、どこかで競合が発生するかどうかはわかりません。また、通常はストアにエイリアスも指定していません。これにより、getStore関数にも問題が発生する可能性があります。

于 2012-08-21T15:30:42.527 に答える