【问题标题】:items does not show in dropdown extJS项目未显示在下拉 extJS 中
【发布时间】:2017-06-06 06:23:08
【问题描述】:

我的页面中有一个组合框?看起来像这样 一家商店

var sourcesStore = new Ext.data.Store({
    autoLoad:true,
    storeId: 'sourcesStore',
    listeners:Ext.ux.loaderListener,
    proxy:new Ext.data.HttpProxy({
        url:'/traffic/traffic_source_list/1',
    }),
    reader:new Ext.data.JsonReader(
        {
            root:'items',
            id:'source_',
            messageProperty:'msg',
            successProperty:'success',
            fields: ['id', 'name']
        },
        ['id', 'name']
    )
});

组合配置

var selectStyleComboboxConfig = {
    fieldLabel: 'My Dropdown',
    name: 'type',
    allowBlank: false,
    editable: false,
    // This is the option required for "select"-style behaviour
    triggerAction: 'all',
    typeAhead: false,
    mode: 'local',
    width: 120,
    listWidth: 140,
    hiddenName: 'traffic_source',
    /*store: [
        ['val1', 'First Value'],
        ['val2', 'Second Value']
    ],*/
    store: sourcesStore,
    readOnly: true
};

在这里设置一个项目

items: [          
      fileField,
      new Ext.form.DateField({
          xtype: 'datefield',
          fieldLabel: 'Start date',
          name: 'startdate',
          format: 'd-m-Y'
      }),
      new Ext.form.DateField({
          xtype: 'datefield',
          fieldLabel: 'End date',
          name: 'enddate',
          format: 'd-m-Y'
      }),

      new Ext.form.ComboBox(selectStyleComboboxConfig)]

问题是它没有在下拉列表中显示要选择的项目。我们在项目中使用 ext 2.3.0 当我单击选择时,我看到一个很长的下拉菜单,但它是空的。我是 extJS 的新手,我迫切需要帮助来解决这个问题。抱歉我的英语不好,如果需要更多信息或细节,请告诉我!

【问题讨论】:

    标签: extjs


    【解决方案1】:

    谢谢,答案很简单。我刚刚添加了

    valueField: 'id',
    displayField: 'name'
    

    现在好了!

    【讨论】:

      猜你喜欢
      • 2017-05-31
      • 2021-11-05
      • 2023-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-29
      • 2020-12-12
      • 2019-01-06
      相关资源
      最近更新 更多