2

我试图在 ext.js 中使用静态值定义一个组合框,但显示的组合框除了 3 个空选项外什么都不显示。

这是代码:

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"

我究竟做错了什么 ?

4

2 回答 2

1

请按照下一个链接的示例

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()
});
于 2012-09-28T12:57:08.333 回答
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"
于 2018-05-25T08:59:22.863 回答