开发者

ExtJS Replace Gridpanel Store

Is there anyway to remotely override/replace a GridPanel's store?

I have a grid that has a dummy store as I get an error if I don't declare as store:

this.ds is undefined

When my form is submitted, it makes a GET REST call & loads a JSON store with the results. I want this store to be the store of my grid and show it underneath the formPanel. I can get it to show & return JSON but can't seem to replace the store.

I tried using searchGrid.store = formStore //the JSONStore returned from form submit

EDIT This if the data store:

var formStore = new Ext.data.JsonStore({
    proxy: new Ext.data.HttpProxy({
        url: '...',
        method: 'GET'
    }),
    root: 'Report',
    fields:[
            ....]
});

This is the loading / changing of the store:

var data = this.getForm().getValues();

        formStore.load({
            params: {
                fields: Ext.encode(data)
            }
        });

        var grid = Ext.getCmp('search');

        Ext.apply(grid, {store: formStore});
        gr开发者_JAVA百科id.show();


Try this

myGridPanel.getStore().proxy.setApi({read: url});
myGridPanel.getStore().load();

I'm using this solution when I want to read data from another url


grid.reconfigure(store, colModel);

Works fine for me. Is the formStore.data compatible with Grid's columns configuration? You don't need to specify the column model in the reconfigure call if it didn't change.

Show a slice of your formStore.data and grid configuration.


Have you tried Ext.apply()?

From the api:

apply( Object object, Object config, Object defaults ) : Object

EDIT:

Here's how you use it:

Ext.apply(myGrid, { store : mystore }); //no need for the third parameter, but if you do want a default, then you can use one


Should the root is inside reader? Like this

var formStore = new Ext.data.JsonStore({
    proxy: new Ext.data.HttpProxy({
        url: '...',
        method: 'GET'
    }),
    reader: {
        type: 'json',
        root: 'Report'
    },
    fields:[
            ....]
});


I managed to solve this by moving the jsonStore to the grid itself and make it a singleton. Then reference to it from the form using StoreMgr

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜