-->

获得在extjs4一个装店(Getting a loaded store in extjs4)

2019-09-21 10:40发布

我得到空当我尝试获取来自控制器的装店。 负载是一次成功的了。 我验证。

我店里如下。

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(); 它说,这是在控制器未定义功能。

我缺少的东西在这里?

Answer 1:

尝试任何这些:

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功能有些困难了。



文章来源: Getting a loaded store in extjs4