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

Extjs 4 grid store MVC with Ext direct url is undefined

我有一个带商店的网格,我想加载渲染或单击按钮,但是当我尝试加载网格时,得到一个 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']

    //...

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]);
}