1. #1
    Ext JS Premium Member
    Join Date
    Oct 2011
    Posts
    84
    Vote Rating
    0
    Webtel is on a distinguished road

      0  

    Exclamation 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)
    Code:
    store_B = Ext.clone(store_A);
    and then :
    Code:
    store_A.load();
    store_B.removeAll();
    ... 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.
    Code:
    var store_B = Ext.apply({},store_A);

  2. #2
    Ext JS Premium Member
    Join Date
    Oct 2011
    Posts
    84
    Vote Rating
    0
    Webtel is on a distinguished road

      0  

    Wink 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
    			}
    		}
    	});
    }

  3. #3
    Sencha User chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    204
    Answers
    42
    Vote Rating
    10
    chramer will become famous soon enough

      0  

    Default


    or maybe just :
    Code:
    Ext.define('definedStore', {...});
    storeA = Ext.create('definedStore');
    storeB = Ext.create('definedStore');

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,004
    Answers
    465
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  5. #5
    Ext JS Premium Member
    Join Date
    Oct 2011
    Posts
    84
    Vote Rating
    0
    Webtel is on a distinguished road

      0  

    Default


    @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.

Thread Participants: 2

Tags for this Thread