PDA

View Full Version : How to reuse store in EXT JS 4 MVC application without multiple reboots?



lfs2008
23 Aug 2012, 5:24 AM
Hello all.
I am working on extjs 4 MVC application.




Application runs the Viewport, which contains tabpanel.
Each tab has own controller and multiple views.


I have one Store used several times (e.g. one tab in combobox, another in the grid.)
Store configured with autoload: true.
Proxy is configured in the Model.


My problem: Store is loaded multiple times - at every mention in the controller [stores] array.


See my code here http://wap7.ru/folio/ext-reuseable-store/TE.html


If I remove one from the array [stores] controller- combobox will be empty, although it states store: Ext.getStore ('STORE-ID')


Please give me a hint, or an example of re-using Store (not Model) as in here docs.sencha .com/ext-js/4-0/#!/guide/mvc_pt2

scottmartin
23 Aug 2012, 4:57 PM
Can you just place the store in your app to make it global?



Ext.application({
stores : [ 'Store' ],
..
});


Scott.

lfs2008
23 Aug 2012, 8:13 PM
No. it does not work
See my code here http://wap7.ru/folio/ext-reuseable-store/TE.html

lfs2008
24 Aug 2012, 3:22 AM
no, if i remove 'Store' from caontroller where i need it, data are not filled.

scottmartin
26 Aug 2012, 7:49 PM
I tested on my app.. it should work fine. Perhaps you can show some code? (app.js)

Are you using autoLoad?

Scott.

lfs2008
27 Aug 2012, 4:49 AM
please see http://wap7.ru/folio/ext-reuseable-store/TE.html

b (http://wap7.ru/folio/ext-reuseable-store/TE.html)oot .js

scottmartin
27 Aug 2012, 5:11 AM
boot.js

stores: [ 'PlatformClient', 'DataType' ]


Create a load listeners for your stores/*.js:
// for each store
listeners: {
load: function() {
console.log(store.load);
}
}

Then add console log to your code in boot.js

Ext.application({
console.log('application');

..

launch:function () {
console.log('launch');
}

See if the firing order is happening as expected. You should not need to call your stores in Main.js

If this does not work, we can look a little closer.

I also noticed your app did not load the first few times (blank page) .. and the combo did not draw completely when it did.

Scott.