具有Ext direct url的Extjs 4网格存储MVC未定义

时间:2015-06-30 10:05:55

标签: extjs model-view-controller extjs4 ext-direct

我有一个带存储的网格,我想加载渲染或单击一个按钮,但是当我尝试加载网格时,得到一个 url未定义错误。我需要使用Ext direct,所以没有url。我该怎么办?

Ext.define('My.view.Grid' ,{
    extend: 'Ext.grid.Panel',
    //...
    store: 'MyStore',
    //...
}

商店:

Ext.define('My.store.MyStore', {
    extend: 'Ext.data.JsonStore',

    //...

    model: 'My.model.MyModel',

    proxy: {
        type: 'direct',
        directFn: Ext.direct.Class.function,
        paramOrder: ['start', 'limit', 'sort', 'active'],
            reader: {
                type: 'json',
                root: "data",
                idProperty: 'id',
                totalProperty: "all"
            },
            extraParams: {
                active: 1
            }
    },
    remoteSort: true,
    sorters: ['name']

    //...

1 个答案:

答案 0 :(得分:1)

Ext.data.Store扩展您的商店:

Ext.define('My.store.MyStore', {
    extend: 'Ext.data.Store',
    // ...
});

如果您看到Ext.data.JsonStore的源代码,您会看到预定义了ajax代理:

constructor: function(config) {
    config = Ext.apply({
        proxy: {
            type  : 'ajax',
            reader: 'json',
            writer: 'json'
        }
    }, config);
    this.callParent([config]);
}