ComboBox 定义有问题。你的 MyPanel 是 Ext.panel.Panel 还是 Ext.panel.Grid ?
var combo = Ext.create('Ext.form.field.ComboBox', {
displayField : 'name',
valueField : 'code',
editable : false,
store : comboStore,
labelAlign : 'right',
width : 260,
labelWidth : 60,
emptyText : '名称',
fieldLabel : '名称',
});
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
]
});
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
valueField: 'abbr',
renderTo: Ext.getBody(),
// Template for the dropdown menu.
// Note the use of "x-boundlist-item" class,
// this is required to make the items selectable.
tpl: Ext.create('Ext.XTemplate',
'
'
'
),
// template for the content inside text field
displayTpl: Ext.create('Ext.XTemplate',
'
'{abbr} - {name}',
'
)
});
boxStore 创建完就 load() 加载
boxStore.load();这句话写在MyPanel创建之前