-
19 Mar 2012 3:19 AM #1
Unanswered: Ext.clone a store
Unanswered: Ext.clone a store
i have a store_A and i want to have one more, similar to this (model,proxy) but loaded independent.
when i do it like : (ExtJS 4.07)
and then :Code:store_B = Ext.clone(store_A);
... both are empty in the end (like they were one object - but documentation says reference should be dropped by Ext.clone.. )Code:store_A.load(); store_B.removeAll();
Is it a bug? or am i doing something wrong?
Is it obligatory to define whole new store separately just for having 2 data sets of same model and source?
PS. following makes no difference.
Code:var store_B = Ext.apply({},store_A);
-
19 Mar 2012 3:47 AM #2
way around
way around
to achieve store cloning i use function similar to following:
Code:clone = function(dict){ return Ext.create(dict.$className,{ proxy:{ url:dict.proxy.url, type: 'ajax', extraParams:dict.proxy.extraParams, simpleSortMode : true, reader: { type: 'json', root: 'rows', totalProperty:'total', successProperty: 'success', idProperty:dict.proxy.reader.idProperty } } }); }
-
19 Mar 2012 3:53 AM #3
or maybe just :
Code:Ext.define('definedStore', {...}); storeA = Ext.create('definedStore'); storeB = Ext.create('definedStore');
-
19 Mar 2012 4:06 AM #4Sencha - Ext JS Dev Team
- Join Date
- Apr 2007
- Location
- Sydney, Australia
- Posts
- 15,097
- Vote Rating
- 97
- Answers
- 169
Clone is only intended to be used on "primitive" type objects, data stores have a whole bunch of complexity that mean they can't really be cloned in a generic manner.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
19 Mar 2012 4:07 AM #5
@chramer
actualy i have one generic store class for all combos. then i create instances of particular lists only chainging proxy extra params.
so i need a copy of already created store because :
- i dont want to rewrite each proxy by hand
- and also i dont want to have 200 separate store class definitions.(for readability sake)
going Your way leads to deifining 200 classes only differing with one extraParam (wile i need just one). Plus 300 instantiations.
The other way is like 1 class definition. Plus 200 instantiations. Plus 100 cloning.


Reply With Quote