1

我有一个带有商店的网格,我想在渲染时加载或单击一个按钮,但是当我尝试加载网格时,得到一个url is undefined错误。我需要直接使用 Ext,所以没有 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']

    //...
4

1 回答 1

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]);
}
于 2015-07-01T22:19:01.877 回答