简体   繁体   English

ext.js组合框无值

[英]ext.js combobox no values

I`m trying to define a combobox in ext.js with static values, but the displayed combobox, doens't show anything but 3 empty oprions. 我正在尝试使用静态值在ext.js中定义一个组合框,但是显示的组合框只显示3个空Oprions。

here's the code: 这是代码:

xtype:"combo",
id: "user_flag",
fieldLabel: "Status",
labelStyle: "width:100px",
store: new Ext.data.SimpleStore({
            fields: ["value", "name"],
            data: [
                  ["-1","Banned"], ["0", "Inactive"], ["1", "Active"]
                  ]
            }),
disaplayField: "name",
valueField: "value",
selectOnFocus: true,
mode: 'local',
editable: false,
triggerAction: "all"

What am I doing wrong ? 我究竟做错了什么 ?

please follow the example of the next link 请按照下一个链接的示例

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.ComboBox http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.ComboBox

    // The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
        {"abbr":"AL", "name":"Alabama"},
        {"abbr":"AK", "name":"Alaska"},
        {"abbr":"AZ", "name":"Arizona"}
        //...
    ]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State',
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
});

Try this instead: 尝试以下方法:

xtype:"combo",
id: "user_flag",
fieldLabel: "Status",
labelStyle: "width:100px",
store: new Ext.data.SimpleStore({
            fields: ["value", "name"],
            data: [
                  ["value":"-1","name":"Banned"], ["value":"0","name":"Inactive"], ["value":"1", "name":"Active"]
              ]
            }),
disaplayField: "name",
valueField: "value",
selectOnFocus: true,
mode: 'local',
editable: false,
triggerAction: "all"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM