【问题标题】:Extjs 4.0.7 paging grid with new proxy带有新代理的 Extjs 4.0.7 分页网格
【发布时间】:2015-07-24 15:07:38
【问题描述】:

我有一个带有商店的分页网格。我必须更改商店的代理,但是当我这样做并尝试重新加载网格时,它会给出一个加载掩码,并且什么也不做。你能帮帮我吗?

这是原店:

var store = new Ext.data.JsonStore({
    autoDestroy: true,
    proxy: {
        type: 'direct',
        directFn: Ext.d.Class.Function,
        extraParams: {
            param: param
        },
        paramOrder: ['param', 'filter', 'start', 'limit', 'sort'],
        reader: {
            type: 'json',
            root: "rows",
            idProperty: 'id',
            totalProperty: "all"
        }
    },
    fields: fields,
    remoteSort: true,
    autoLoad: false,
    sorters: sorters
});

原始网格:

var grid = Ext.create('Ext.grid.Panel', {
    selModel: selmodel,
    title: title,
    flex: 1,
    store: store,
    columns: columns,
    bbar: pager = Ext.create('Ext.PagingToolbar', {
        store: store,
        displayInfo: true,
        displayMsg: '{1} / {2}',
        emptyMsg: ""
    })
//...

新代理:

var newProxy = Ext.create('Ext.data.Proxy', {
    type: 'ajax',
    paramsAsHash: false,
    url: 'tasks.php',
    actionMethods: {
        read: 'POST'
    },
    extraParams: {
        task: 'getItems',
        id: id
    },
    reader: {
        type: 'json',
        root: "rows",
        idProperty: 'id',
        totalProperty: "all"
    }
});

我尝试设置代理并加载商店,但它什么也没做。

grid.getStore().removeAll();
grid.getStore().setProxy(newProxy);
grid.getDockedItems()[2].store.setProxy(newProxy);
grid.getStore().load(); // fails, loading mask but no ajax

有什么想法吗?

【问题讨论】:

    标签: extjs proxy extjs4


    【解决方案1】:

    那是因为您实际上并没有创建 Ajax 代理,而是它的父类 Ext.data.Proxytype 不会在这些行中解释:

    var newProxy = Ext.create('Ext.data.Proxy', {
        type: 'ajax',
    

    你必须指定实际的类名:

    var newProxy = Ext.create('Ext.data.proxy.Ajax', {
    

    (而且,恕我直言,您最好使用新关键字 new Ext.data.proxy.Ajax 创建它,以便您尽早发现您的缺失需要...)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-20
      • 1970-01-01
      • 2012-04-11
      • 2014-11-13
      • 2014-05-07
      • 2012-06-27
      • 1970-01-01
      • 2013-08-02
      相关资源
      最近更新 更多