簡體   English   中英

在extjs4中獲取加載的商店

[英]Getting a loaded store in extjs4

當我嘗試從控制器獲取加載的存儲時,我變為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(); 這說它是控制器中未定義的功能。

我在這里錯過了一些東西嗎?

嘗試以下任何一個:

this.getSchemedatastoreStore()

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

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

如果您沒有定義自己的商店ID,MVC模式將自動為商店提供商店類名稱作為商店ID。

因此,如果您刪除storeId: 'schemedatastoreid'配置,那么您將自動獲得schemedatastore的schemedatastore 我通常不會給MVC商店一個單獨的storeId配置,所以我不知道它是否會在某個地方引起沖突。 我通常也不會給我的商店一個別名,這可能會導致getStore功能也有一些困難。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM