我正在使用MVC示例here,並繞過了PhoneGap聯繫人數據,並將其替換爲我自己的模型和商店。當我將一個列表添加到面板時,我將其指向myApp.stores.products。清單是一個數據視圖,所以tpl
,store
,並要求itemSelector
,但是例如省略itemSelector
並使用itemTpl
代替tpl
...添加了所需的DataView配置,但仍然出現錯誤? (tpl:vs itemTpl)
items: [{
xtype: 'list',
store: myApp.stores.products,
itemTpl: '{productName}',
onItemDisclosure: function (record) {
//Ext.dispatch({
// controller: myApp.controllers.products,
// action: 'show',
// id: record.getId()
//});
}
}]
當然,我得到一個控制檯的警告如下:
Uncaught DataView requires tpl, store and itemSelector configurations to be defined.
於是,我改變配置什麼,我知道它應該是現在得到一個錯誤......
items: [{
xtype: 'list',
store: myApp.stores.products,
tpl: '{productName}',
itemSelector: 'div.productView',
onItemDisclosure: function (record) {
//Ext.dispatch({
// controller: myApp.controllers.products,
// action: 'show',
// id: record.getId()
//});
}
}]
Uncaught Error: Ext.List: itemTpl is a required configuration.
那麼,這是什麼? itemTpl或tpl?爲什麼Ext.List不知道要使用哪個?我甚至嘗試添加tpl
和itemTpl
,爲了安全起見,仍然得到了上述兩個錯誤中的第一個。
注: 這就是它看起來像在面板方面:
myApp.views.ProductList = Ext.extend(Ext.Panel, {
dockedItems: [{
xtype: 'toolbar',
title: 'Products'
}],
items: [{
xtype: 'list',
store: myApp.stores.products,
tpl: '{productName}',
itemSelector: 'div.productView',
onItemDisclosure: function (record) {
//Ext.dispatch({
// controller: myApp.controllers.products,
// action: 'show',
// id: record.getId()
//});
}
}],
initComponent: function() {
myApp.stores.products.load();
myApp.views.ProductList.superclass.initComponent.apply(this, arguments);
}
});
UPDATE: 我認爲這是barfing在initComponent.apply()...
myApp.views.ProductList.superclass.initComponent.apply(this, arguments);
很酷,謝謝! JS確實是一種特殊語言;) –