0

我无法将内联数组数据加载到商店中。特别是,这失败了。有人可以解释为什么吗?我什至尝试使用数组读取器添加内存代理,但仍然没有骰子。

Ext.define('MyApp.store.ComboboxState', {
extend: 'Ext.data.Store',

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        autoLoad: true,
        storeId: 'ComboboxState',
        data: [
            [
                'AL',
                'Alabama'
            ]
           ]
        ,fields: [
            {
                name: 'state'
            },
            {
                name: 'name'
            }
        ]
    }, cfg)]);
}
});

仍然不适用于此内存代理/数组读取器:

        proxy: {
            type: 'memory',
            reader: {
                type: 'array'
            }
        }
4

1 回答 1

0

只需从 ArrayStore 扩展,如下所示:

Ext.define('MyApp.store.ComboboxState', {
    extend: 'Ext.data.ArrayStore',

    constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
        me.callParent([Ext.apply({
            autoLoad: true,
            storeId: 'ComboboxState',
            data: [
                [
                    'AL',
                    'Alabama'
                ]
            ]
            ,fields: ['state', 'name' ]
        }, cfg)]);
    }
});

JsFiddle 尝试:http: //jsfiddle.net/voidmain/hKwbJ/

于 2013-03-12T18:59:42.457 回答