【发布时间】:2015-07-09 05:45:30
【问题描述】:
在我的 ViewModel 中,我为我在视图中绑定到的 ComboBox 创建了一个内联数据存储。我遇到的问题是根据商店中的一个值为 ComboBox 设置默认值...我可能在这里理解绑定,所以我想听听任何反馈。
OrderDetailsStatus 模型:
Ext.define('UserUI.model.OrderDetailsStatus', {
extend: 'Ext.data.Model',
alias: 'model.OrderDetailsStatus',
fields: [{
type: 'int',
name: 'statusId'
},
{
type: 'string',
name: 'status'
}]
});
视图模型:
stores: {
/* TODO: This could eventually become an AJAX call, but for right now,
* it's an inline data store... the statusId's are currently unused */
orderDetailsStatusStore: {
model: 'UserUI.model.OrderDetailsStatus',
proxy: {
type: 'memory'
},
data: [
{ status: 'All', statusId: 1 },
{ status: 'Correct', statusId: 2 },
{ status: 'Incorrect', statusId: 3 }
]
}
}
在视图中:
{
xtype: 'combo',
fieldLabel: 'Status',
bind: {
store: '{orderDetailsStatusStore}'
},
valueField: 'status',
displayField: 'status',
queryMode: 'local',
value: 'All',
listeners: {
select: 'onSelectComboBoxStatus'
}
}
使用值:'All' 给我一个关于模型不存在的错误:
TypeError: Model is not a constructor: ext-all...ebug.js (line 122343, col 33)
record = new Model(dataObj);
我假设这是因为绑定的商店尚未完全加载?如果我在该行调试代码,模型是未定义的,并且商店没有任何数据。任何帮助将不胜感激。
【问题讨论】: