Ext JS - What is the best way to clone to and from a store?

4.5k Views Asked by At

I have a permanent data store . I want to clone the records to a temporary data store,make changes to the records and then copy the modified records back to the permanent store.

I created the temporary store like this:-

permanentStore.each(function (record) { 
    temporaryStore.add(record.copy());}
);

How do I copy back only the modified records ? Do I need to find the matching records using id for all the modified records or is there any other easy way?

permanentStore.findRecord('Id','temporaryStoreRecordId') 

Is there any clean way of cloning so that the changes are applied to the permanent store automatically ?

1

There are 1 best solutions below

0
Ronak Patel On

You can use clone method to clone all records.

var clonerecord = Ext.clone(records);

temporaryStore.add(cloneRecord);

temporaryStore.getModifiedRecords(); to get modified records.

temporaryStore.getNewRecords(); to get new records.

temporaryStore.getRemovedRecords(); to get remove records.