PDA

View Full Version : Get modified records, cloning and reject the changes



cristiano.gregnanin
23 Sep 2014, 2:06 AM
Hy, using 3.4 .
I am trying to get modified records from store, iterate the array , clone each record discarding the current changes and setting a field:



for ( var i = 0;i < modifiedRecords.length;i++) {
var rec=gridStore.getAt(gridStore.find("id",modifiedRecords[i].get("id")))).copy(); // clone the record
Ext.data.Record.id(rec); // automatically generate a unique sequential id
rec.set("data_fine",new Date());
if (rec){
alertAll(rec);
gridStore.add(rec);

modifiedRecords[i].cancelEdit();
}

This code doesn't works. The add method don't add the record in the store and the cancelEdit method don't restore the record at the orginal state (before editing)

slemmon
14 Oct 2014, 3:01 AM
Try using the reject() method instead of cancelEdit()
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.Record-method-reject

cristiano.gregnanin
14 Oct 2014, 3:06 AM
Try using the reject() method instead of cancelEdit()
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.Record-method-reject
Thanks it works for me .