ext.js组合框没有值

时间:2012-09-28 07:07:27

标签: javascript extjs combobox

我试图在ext.js中使用静态值定义一个组合框,但是显示的组合框除了显示3个空的oprions之外不会显示任何内容。

这是代码:

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"

我做错了什么?

2 个答案:

答案 0 :(得分:0)

请按照下一个链接的示例

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()
});

答案 1 :(得分:0)

请改为尝试:

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"