PDA

View Full Version : Using storeId on a Ext.data.Store isn't making unique instances



hallikpapa
20 Jul 2012, 6:32 AM
I have a store `APP.store.Posts` that I want to instantiate 3 different times. They will all hold the same type of data, but will be using different parameters when reloading, paging, etc. In a controller, I do this in the `onLaunch` function.



onLaunch: function() {

Ext.create('APP.store.Posts',{
storeId: 'unclassifiedPosts'
});
Ext.create('APP.store.Posts',{
storeId: 'positivePosts'
});
Ext.create('APP.store.Posts',{
storeId: 'negativePosts'
});
},


Then later, in the `beforerender` listener methods I created on the controller, I do this:



beforeRenderPostsGrid: function(grid) {
var store = Ext.getStore('unclassifiedPosts');
store.load();
},
beforeRenderPositivePostsGrid: function(grid) {
var store = Ext.getStore('positivePosts');
store.getProxy().extraParams = {'some_param' : 'some_value'};
store.load();
var checkOtherStore = Ext.getStore('unclassifiedPosts'); //THIS STORE NOW HAS SAME PARAMS AS positivePosts STORE
},


The problem is, whichever `beforerrender` grid is called last, all 3 stores have those parameters. So the initial load is fine, but if I do any refresh, paging, etc. They all show the same data b/c the proxies for each store have identical extraParams somehow.

From what I understood, the `storeId` parameter was supposed to make my store unique, so am I missing a step?

hallikpapa
20 Jul 2012, 8:08 AM
Turns out, this is because I am assigning the proxy on the model, whereas in this instance, I need to do it on the store.