0
votes

I have a paging grid with a store. I have to change the proxy of the store, but when i do this and try to reload the grid, it gives a loading mask and do nothing else. Can you help me?

This is the original store:

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

The original grid:

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: ""
    })
//...

The new proxy:

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

And I tried to set proxy and load the store, but it doesn't do anything.

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

Any idea?

1

1 Answers

1
votes

That's because you're not actually creating an Ajax proxy, but its parent class Ext.data.Proxy. The type is not interpreted in these lines:

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

You have to specify the actual class name:

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

(And, IMHO, you'd better create it with the new keyword new Ext.data.proxy.Ajax, so that you discover your missing requires early...)