PDA

View Full Version : datastore and multiple windows information



bozzoz
4 Oct 2010, 11:05 PM
Hello, when I create two or more windows with the same grid and relative datastore in the designer, at run time, does each window have its own instance of the datastore?

Thanks

jarrednicholls
5 Oct 2010, 4:03 AM
Hi bozzoz,

Each window will be sharing the same instance of Store, which is looked up via the Ext.StoreMgr. If this is not what is desired, you can clear the store configuration for one of the grids and configure a new instance in your implementation code.

bozzoz
5 Oct 2010, 5:20 AM
Thank you Jarred!

bozzoz
14 Jan 2011, 12:26 AM
Hi Jarred, how do I reset the store configuration and set the new instance? Can you post me an example?
Thanks

My code


tabPraticheCommittente = Ext.extend(tabPraticheCommittenteUi, {
initComponent: function() {
tabPraticheCommittente.superclass.initComponent.call(this);

var store = new storeElencoPraticheCommittente();
var grid = this.gridElencoPratiche;

this.btAdd.on('click', this.btAddClick, this);
this.btEdit.on('click', this.btEditClick, this);
this.btDel.on('click', this.btDelClick, this);
this.gridElencoPratiche.on('rowdblclick', this.btEditClick, this);
this.on('activate', this.onTabActivate, this);

var sm = this.gridElencoPratiche.getSelectionModel();
sm.on('selectionchange', this.gridSelectionIsChanged, this);

},
...

jarrednicholls
14 Jan 2011, 6:25 AM
Maybe something like this...



tabPraticheCommittente = Ext.extend(tabPraticheCommittenteUi, {
initComponent: function() {
tabPraticheCommittente.superclass.initComponent.call(this);

var store = new storeElencoPraticheCommittente();
var grid = this.gridElencoPratiche;

// Reconfigure the grid with a new Store and its same column model
// See: http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.GridPanel&member=reconfigure
// There are caveats to note in the documentation of "reconfigure"
grid.reconfigure(store, grid.getColumnModel());

this.btAdd.on('click', this.btAddClick, this);
this.btEdit.on('click', this.btEditClick, this);
this.btDel.on('click', this.btDelClick, this);
this.gridElencoPratiche.on('rowdblclick', this.btEditClick, this);
this.on('activate', this.onTabActivate, this);

var sm = this.gridElencoPratiche.getSelectionModel();
sm.on('selectionchange', this.gridSelectionIsChanged, this);

},
...

bozzoz
17 Jan 2011, 1:21 AM
Thank you Jarred, the ExtJs API is very big and when I looked I missed the reconfigure method!

I also reconfigured the paging toolbar in this way:



tabPraticheCommittente = Ext.extend(tabPraticheCommittenteUi, {
initComponent: function() {
tabPraticheCommittente.superclass.initComponent.call(this);

var store = new storeElencoPraticheCommittente();
store.setBaseParam('id_committente', this.ownerCt.ownerCt.tabAnagraficaCommittente.id_committente.getValue());
var grid = this.gridElencoPratiche;
grid.reconfigure(store, grid.getColumnModel());
//rebind the paging toolbar with the new store - associo alla paging toolbar il nuovo store
grid.getBottomToolbar().bindStore(store);

this.btAdd.on('click', this.btAddClick, this);
this.btEdit.on('click', this.btEditClick, this);
this.btDel.on('click', this.btDelClick, this);
this.gridElencoPratiche.on('rowdblclick', this.btEditClick, this);
this.on('activate', this.onTabActivate, this);

var sm = this.gridElencoPratiche.getSelectionModel();
sm.on('selectionchange', this.gridSelectionIsChanged, this);

}
...


Thanks!