View Full Version : Ext.clone a store

19 Mar 2012, 3:19 AM
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)

store_B = Ext.clone(store_A);

and then :


... both are empty in the end (like they were one object - but documentation says reference should be dropped by Ext.clone.. )

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.

var store_B = Ext.apply({},store_A);

19 Mar 2012, 3:47 AM
to achieve store cloning i use function similar to following:

clone = function(dict){
return Ext.create(dict.$className,{
type: 'ajax',
simpleSortMode : true,
reader: {
type: 'json',
root: 'rows',
successProperty: 'success',

19 Mar 2012, 3:53 AM
or maybe just :

Ext.define('definedStore', {...});
storeA = Ext.create('definedStore');
storeB = Ext.create('definedStore');

19 Mar 2012, 4:06 AM
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.

19 Mar 2012, 4:07 AM
@chramer (http://www.sencha.com/forum/member.php?240566-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.