【问题标题】:Extjs 4 grid store MVC with Ext direct url is undefined带有 Ext 直接 url 的 Extjs 4 网格存储 MVC 未定义
【发布时间】:2015-06-30 10:05:54
【问题描述】:

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

    //...

【问题讨论】:

  • 您的问题解决了吗?如果是,请接受我的回答,如果不是,请发表评论。谢谢!

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


【解决方案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]);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-18
    • 2011-08-18
    • 2011-12-24
    • 2014-05-07
    • 2012-08-20
    • 1970-01-01
    • 2014-11-18
    • 2013-05-08
    相关资源
    最近更新 更多