Extjs getStore();未定义的Sencha Touch 2
我有两个存储加载的数据 第一家店:Extjs getStore();未定义的Sencha Touch 2,extjs,store,Extjs,Store,我有两个存储加载的数据 第一家店: Ext.define('Connecting.store.Groups', { extend: 'Ext.data.Store', requires: [ 'Connecting.model.groupModel', 'Ext.data.proxy.Ajax', 'Ext.data.reader.Json' ], config: { autoLoad: true
Ext.define('Connecting.store.Groups', {
extend: 'Ext.data.Store',
requires: [
'Connecting.model.groupModel',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
config: {
autoLoad: true,
model: 'Connecting.model.groupModel',
storeId: 'Groups',
proxy: {
type: 'ajax',
url: 'http://localhost/php/getGroups.php',
reader: {
type: 'json'
}
}
}
});
Ext.define('Connecting.store.Secondgroups', {
extend: 'Ext.data.Store',
requires: [
'Connecting.model.Secondgroup',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
config: {
autoLoad: true,
model: 'Connecting.model.Secondgroup',
storeId: 'Secondgroup',
proxy: {
type: 'ajax',
url: 'http://localhost/php/getSecondGroup.php',
reader: {
type: 'json'
}
}
}
});
第二商店:
Ext.define('Connecting.store.Groups', {
extend: 'Ext.data.Store',
requires: [
'Connecting.model.groupModel',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
config: {
autoLoad: true,
model: 'Connecting.model.groupModel',
storeId: 'Groups',
proxy: {
type: 'ajax',
url: 'http://localhost/php/getGroups.php',
reader: {
type: 'json'
}
}
}
});
Ext.define('Connecting.store.Secondgroups', {
extend: 'Ext.data.Store',
requires: [
'Connecting.model.Secondgroup',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
config: {
autoLoad: true,
model: 'Connecting.model.Secondgroup',
storeId: 'Secondgroup',
proxy: {
type: 'ajax',
url: 'http://localhost/php/getSecondGroup.php',
reader: {
type: 'json'
}
}
}
});
第一家商店工作
var store = Ext.getStore('Groups');
console.log(store);
但是当我将storeId
更改为“Secondgroup
”(在getStore中)时,我的控制台.log
将给我一个未定义的
我似乎找不到问题。。有什么建议我应该朝哪个方向看
另外,我正在使用Sencha Architect,但这不应该是一个问题。Sencha Touch实际上使用了您在定义中使用的内容
对于第二个组,尝试使用Ext.getStore('Secondgroups');这应该对你有用 你能设置一个JSFIDLE吗?愚蠢的问题。。。但是你确定第二个存储已经加载并实例化了吗?我使用Architect创建了这个存储,我可以看到它已经完全加载了记录。我不确定它是否被实例化了,但据我所知,我以前从未这样做过……或者我可能是在不知情的情况下这么做的。你是否在“第二组”中删除了一个“s”,或者这是一个拼写错误?是的,我也注意到了,我更改了它,使所有(商店、模型和商店ID)现在都有相同的名称(第二组)但它仍然给我一个未定义的…我找到了解决方案!我定义了商店,但不知何故,当我的第一家商店创建时,它还没有被创建。我唯一要做的就是:Ext.create('Connecting.store.Secondgroups',{});然后我使用var store=Ext.getStore('Secondgroups');在那之后,“未定义”就消失了,我可以填满我的商店:)