Getting a loaded store in extjs4

北城余情 提交于 2019-12-22 10:29:06

问题


I am getting null while I try to obtain a loaded store from the controller. The load is a successful one too. I verified that.

I have the store as follows.

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.');
        },
    }
});

In my controller I added like,

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

I tried accessing in these both ways in the controller,

Ext.getStore('schemedatastoreid'); which returns null and this.getschemedatastoreStore(); which says it is an undefined function in controller.

Am I missing something over here?


回答1:


Try any of these:

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 pattern will give your store the store class name as a store ID automatically if you don't define your own.

So if you delete your storeId: 'schemedatastoreid' config then you will automatically get a storeId of schemedatastore. I don't normally give MVC stores a seperate storeId config so I don't know if it causes a conflict somewhere. I also don't normally give my stores an alias either, that might be causing the getStore function some difficulties too.



来源:https://stackoverflow.com/questions/12058210/getting-a-loaded-store-in-extjs4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!