PDA

View Full Version : Assign a store dynamically to a grid by button



openminds2010
8 Apr 2010, 12:06 PM
Hello there,

I just try to figure out how I can manage it to assign different stores to an existing grid?
In my application I create different stores and if I assign it by the

store: mainStoreproperty, everything works fine.

Now I want to change the store dynamically by an action ie. of a button.

Perhaps someone has managed it before?
cheers
Mario

steffenk
8 Apr 2010, 12:50 PM
What did you tried?

openminds2010
8 Apr 2010, 12:56 PM
Hi Steffen,

wow, is there any forum you don't give support? :-)

I tried the following:


handler: function(){
Ext.StoreMgr.get('secondStore').reload();
}


but my Component does not reload...
Any ideas?

regards
Mario

woozy
8 Apr 2010, 5:02 PM
Why do you want different stores?

Can't you use the same store but load it with diferent params?

Nesta
8 Apr 2010, 10:59 PM
form the api doc:





reconfigure (http://www.extjs.com/forum/../deploy/dev/docs/source/GridPanel.html#method-Ext.grid.GridPanel-reconfigure)( Ext.data.Store store, Ext.grid.ColumnModel colModel ) :
Reconfigures the grid to use a different Store and Column Model and fires the 'reconfigure' event. The View will be bound to the new objects and refreshed.
Be aware that upon reconfiguring a GridPanel, certain existing settings may become invalidated. For example the configured autoExpandColumn (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.grid.GridPanel.html#Ext.grid.GridPanel-autoExpandColumn) may no longer exist in the new ColumnModel. Also, an existing PagingToolbar (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.PagingToolbar.html) will still be bound to the old Store, and will need rebinding. Any plugins (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.grid.GridPanel.html#Ext.grid.GridPanel-plugins) might also need reconfiguring with the new data.
Parameters:

store : Ext.data.StoreThe new Ext.data.Store (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.data.Store.html) object
colModel : Ext.grid.ColumnModelThe new Ext.grid.ColumnModel (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.grid.ColumnModel.html) object

Returns:

void




so just create your new soore and ColumnModel and call GridPanel.reconfigure

if the url dousnt change you can change the baseparams to pass different params to the server. maybe thats a enough because reconfigure completely alters the grid and is slower as just change params

openminds2010
8 Apr 2010, 11:36 PM
That's great!
I am going to check this.

Thanks for your help!
regards
Mariop