Extjs 未定义Ext.StoreManager.lookup中的查找
我的看法是:Extjs 未定义Ext.StoreManager.lookup中的查找,extjs,sencha-touch-2,Extjs,Sencha Touch 2,我的看法是: Ext.define('MyApp.view.Login.LoginForm',{ extend: 'Ext.form.Panel', alias: 'loginForm', requires: ['Ext.form.FieldSet', 'Ext.Img'], config: { items: [ { xtype: 'fieldset', ite
Ext.define('MyApp.view.Login.LoginForm',{
extend: 'Ext.form.Panel',
alias: 'loginForm',
requires: ['Ext.form.FieldSet', 'Ext.Img'],
config: {
items: [
{
xtype: 'fieldset',
items: [
{
xtype: 'textfield',
name: 'username',
required: true
},{
xtype: 'textfield',
name: 'password',
required: true,
inputType: 'password'
},{
xtype: 'selectfield',
//*****************the problem is here****************
store: Ext.StoreManager.lookup('MyApp.store.Tables')
//store: Ext.StoreManager.lookup('Tables')
}
]
},{
xtype: 'button',
text: 'Login',
}
]
}
});
它说它不能使用查找未定义的
,所以我认为MyApp看不到Ext.StoreManager
我还尝试了Ext.data.StoreManager.lookup
和Ext.StoreMgr
。
顺便说一句,这家商店确实存在。请尝试按照以下说明操作,并让我知道它是否有效:
app.js
文件中Tables.js
store实现文件中,在其配置中为其指定一个storeId
,如下所示:config:{storeId:'Tables'}
store:'Tables'
希望有帮助。您的商店配置应如下所示:
Ext.define('MyApp.store.Tables', {
extend: "Ext.data.Store",
config: {
model: "MyApp.model.Table",
data : [{
text: "Ed",
value: "Spencer"
}, {
text: "Tommy",
value: "Maintz"
}]
}
});
并将其放入您的LoginForm.js中:
{
xtype: 'selectfield',
store: 'Tables'
}
我已经测试过了。工作正常。工作正常!非常感谢。还有一个问题,这是Sencha Touch 2还是ExtJS 4新版本中的变化?在ExtJS 4的早期版本中,我会查找store.Lol没关系,兄弟,抱歉我的简短:)关于你关于storeId的问题,是的,它在这种情况下仍然有效,因为在命令
store:'Tables'
后面,Sencha Touch会查找相应的类名,即yourApp.store.Tables
。但是如果有时您想直接通过这个Ext.getStore('Tables')
Ext.getStore
是您以前尝试使用的Ext.data.StoreManager.lookup
的简写形式,则不会这样做,这就是为什么我提到了storeId
;)@泰姆:我想纠正你,先生。你的最后一行错了Ext.getStore('Tables')
在没有storeId
的情况下也可以工作。@AnandGupta:它可能会工作,但只有在这种情况下:定义没有storeId的存储,然后使用Ext.getStore()
并传递由框架本身创建的存储的指定id,在本例中为“Tables”。如果您将storeId更改为smt-else,比如“store.Tables”,Ext.getStore(“Tables”)将返回undefined
,并且在所有情况下,都不依赖于框架创建的默认id的存在。相反,显式声明重要配置总是更好的做法,对吗?