【问题标题】:Create store data from array and bindStore in Combobox Extjs 4在 Combobox Extjs 4 中从数组和 bindStore 创建存储数据
【发布时间】:2014-11-10 01:16:41
【问题描述】:

我在使用 ArrayStore 动态填充组合框时遇到问题。

控制器中: 我有一个 StatusArray : ["Active", "Inactive", "Closed"] 我创建了一个如下所示的商店

var test = Ext.create('Ext.data.ArrayStore', {
            fields: [
                { name: "Status" }
            ],
            data: StatusArray
        });

然后我用这个商店填充组合框

Ext.ComponentQuery.query('#statusId')[0].bindStore(test);

它可以工作,但组合框只获取 StatusArray 中每个值的第一个字母,例如“A”、“I”、“C”。

我的表单查看与组合框:

items: [{
        xtype: 'form', itemId: 'eventForm', bodyPadding: 10, anchor: '100%',
        items: [{ xtype: 'combobox', anchor: '100%', displayField: 'Status', name: 'Status', valueField: 'Status', typeAhead: true, queryMode: 'local', triggerAction: 'all', fieldLabel: ' Status ', emptyText: 'Select Status', tooltip: 'Select Status', selectOnFocus: true, itemId: 'statusId' },
            { xtype: 'button', itemId: 'submitButton', text: 'Submit' }
        ]
    }],

谁能帮我解决这个问题?谢谢!!!

【问题讨论】:

    标签: arrays combobox extjs4 store


    【解决方案1】:

    数据对象(statusarray)应该是模型实例的数组或数据对象的形式来本地加载...

    使用

    StatusArray : [["Active"], ["Inactive"], ["Closed"]]

    StatusArray : [{"Active"}, {"Inactive"}, {"Closed"}]

    您可以查看ArrayStore here的示例代码

    【讨论】:

    • 谢谢您的回答!!!但是我怎样才能将 [ ] 放在 StatusArray 之外? StatusArray 是动态创建的,我不能像你写的那样去编辑它。
    猜你喜欢
    • 1970-01-01
    • 2012-12-31
    • 1970-01-01
    • 2017-12-18
    • 2012-02-14
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 2014-09-16
    相关资源
    最近更新 更多