用静态数据填充Extjs组合框

用静态数据填充Extjs组合框,extjs,extjs4,Extjs,Extjs4,我的基类中有一个组合框,在这里我只配置“fields”属性。像这样: items: [ comboText = Ext.create('Ext.form.ComboBox', { width: 150, padding: '0 20 0 0', displayField: 'label', store: Ext.create('Ext.data.Store'

我的基类中有一个组合框,在这里我只配置“fields”属性。像这样:

items: [
      comboText = Ext.create('Ext.form.ComboBox', {
                width: 150,
                padding: '0 20 0 0',
                displayField: 'label',
                store: Ext.create('Ext.data.Store', {
                    fields: [
                        {type: 'string', name: 'label'},
                        {type: 'string', name: 'fieldName'}
                    ]
                })
            }),
...]
如何仅将数据属性传递给此组合? 我尝试了以下代码,但不起作用:

comboTest.store.loadData(value);
其中value包含如下数组:

 [
    {"label":"First name", "fieldName":"firstname"},
    {"label":"Birth date", "fieldName":"birthdate"}
 ]
没有错误,但组合框不会打开任何内容。

尝试以下配置:

       xtype:'combo',
       fieldLabel:'Division',
       name:'division',
       queryMode:'local',
       store:['A','B','C'],
       displayField:'division',
       autoSelect:true,
       forceSelection:true
另一个备选方案列在右侧:


valueField
对于组合框是必需的。尝试在组合框中设置
valueField

我是通过以下方式实现的:

   xtype:'combo',
   fieldLabel:'Division',
   name:'division',
   valueField: 'division',
   queryMode:'local',
   store:['A','B','C'],
   displayField:'division',
   autoSelect:true,
   forceSelection:true
我知道这个问题真的很古老,但以防有人来寻找一个现成的答案;对我来说,这就是它。

它有效:

{
    name: 'sample',
    xtype: 'combobox',
    allowBlank: false,
    emptyText: 'select ...',
    queryMode: 'local',
    itemId: 'sample',
    id: 'sample',
    displayField: 'name',
    valueField: 'name',
    forceSelection:true,
    store: ['B','C', 'A'],
    typeAhead: true
}
而不是使用loadData()

使用loadRawData()


如果有困惑,请尝试一下

我喜欢这个简单的解决方案。对API手册的参考,其中描述了这一点:查找存储配置。
{
    name: 'sample',
    xtype: 'combobox',
    allowBlank: false,
    emptyText: 'select ...',
    queryMode: 'local',
    itemId: 'sample',
    id: 'sample',
    displayField: 'name',
    valueField: 'name',
    forceSelection:true,
    store: ['B','C', 'A'],
    typeAhead: true
}
comboTest.store.loadData(value);
comboTest.store.loadRawData(value);