Ben Irving
Ben Irving

Reputation: 493

ExtJS Duplicate Store Record

I want to take a record from a store, and duplicate it. Is there a way of doing in by default in ExtJs? I've looked through the docs and cannot find a way.

Upvotes: 4

Views: 2287

Answers (1)

Tarabass
Tarabass

Reputation: 3152

You can take a record from the store and copy it. After that add the clone to the store.

http://docs.sencha.com/extjs/6.0/6.0.0-classic/#!/api/Ext.data.Model-method-copy

var rec = record.copy(null); // clone the record but no id (one is generated)
myStore.add(rec);

You can also clone it, which will preserve changes.

http://docs.sencha.com/extjs/6.0/6.0.0-classic/#!/api/Ext.data.Model-method-clone

Upvotes: 5

Related Questions