使用“ext-designer-for-ext-js-4-users-guide.pdf”中的示例,我将以下内容放在一起。问题是商店没有约束力。即选择是空的。extjs组合框不绑定到数组存储
MyComboBox.js
Ext.define('MyApp.view.MyComboBox', {
extend: 'MyApp.view.ui.MyComboBox',
initComponent: function() {
var me = this;
me.callParent(arguments);
}
});
Ext.define('MyApp.view.ui.MyComboBox', {
extend: 'Ext.form.field.ComboBox',
fieldLabel: 'comboList',
displayField: 'comboList',
queryMode: 'local',
store: 'MyArrayStore',
triggerAction: 'all',
valueField: 'comboList',
initComponent: function() {
var me = this;
me.callParent(arguments);
}
});
店/ MyArrayStore.js
Ext.define('MyApp.store.MyArrayStore', {
extend: 'Ext.data.Store',
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
storeId: 'MyArrayStore',
data: [
[
'Search Engine'
],
[
'Online Ad'
],
[
'Facebook'
]
],
proxy: {
type: 'ajax',
reader: {
type: 'array'
}
},
fields: [
{
name: 'comboList'
}
]
}, cfg)]);
}
});
**更新**
这是推动我疯了。它的[turns out][1]
我的数组需要是json格式。当我把它更新到
[{ “comboList”: “你好”},{ “comboList”: “嗨”},{ “comboList”: “早安”}]
它的工作。
感谢Geronimo中。真的很感激写出来的时间。我复制了第一次使用它的代码。问题是我的数据格式不正确。你的数据是正确的,我给你答案。出于兴趣,你使用MVC方法工作吗? – frosty 2012-01-13 11:35:34