在extjs4中获取加载的存储 [英] Getting a loaded store in extjs4
问题描述
当我尝试从控制器获取一个加载的存储时,我变为null。负载也是成功的。我已经验证了。
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.
我有这个商店如下。
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');
它返回null和
this.getschemedatastoreStore();
这说明它是控件中的一个未定义的函数。
Ext.getStore('schemedatastoreid');
which returns null and
this.getschemedatastoreStore();
which says it is an undefined function in controller.
我在这里遗漏了一些东西吗?
Am I missing something over here?
推荐答案
尝试以下任何一种:
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。
MVC pattern will give your store the store class name as a store ID automatically if you don't define your own.
所以如果你删除你的 storeId:'schemedatastoreid'
config然后你会自动获得一个storeId为 schemedatastore
。我通常不会给MVC存储一个单独的 storeId
config,所以我不知道它是否在某处造成冲突。我通常也不会给我的商店一个别名,这可能会导致 getStore
功能一些困难。
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.
这篇关于在extjs4中获取加载的存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!