Extjs grid里某个column的xtype为combobox,怎样在页面ready的时候加载combobox下拉列表理的数据?

2025-05-13 03:26:03
推荐回答(3个)
回答(1):

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 : '名称',
});

回答(2):

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',
'',
'

{abbr} - {name}
',
''
),
// template for the content inside text field
displayTpl: Ext.create('Ext.XTemplate',
'',
'{abbr} - {name}',
'
'
)
});

回答(3):

boxStore 创建完就 load() 加载

boxStore.load();这句话写在MyPanel创建之前