View Full Version : Copy, Duplicate or Clone Store (ExtJs 4)

13 Dec 2011, 1:17 AM

I have a store from a json file that i want copied. How is this done!?

Some help is available for this but I am not able to do it with ExtJS 4.

var newStore= new Ext.data.Store({
model : oldStoreModel
oldStore.each(function (r){
records.push (r.copy());

In the above the newStore is empty...

13 Dec 2011, 2:15 AM
well, a store definitely should get more configs than just a model definition and you should not pass that one in via reference.

i would go the mvc way: create a custom class for your model using Ext.define(). Create a class for you store as well using the model. Create a new instance (using Ext.create() instead of new) of the store, then you can load the data from the first store.

-> Creating a Model and a Store

13 Dec 2011, 2:33 AM
Hehehe... Not so simple I see...

I need this in order to show only part of the records of a store in a graph. IŽll just go with plan B and generate an optimized json for the graph...

Nevertheless, thank you for your reply.

13 Dec 2011, 2:45 AM
you can also filter the store ->


the approach to create reuseable components is not difficult to implement.