So lets start with solution(click X button and look into the console): FIDDLE
Now what happens here is that i manually call my own added function in store called markDirtyFix
and pass it a record(which i want to mark as dirty) to put it in modified-records list. Actually it is a copied function afterEdit
from store. I just commented fireEvent of update(because this forces request to be sent on update, and you want to make it dirty "only locally"):
afterEdit: function(record){
if(this.modified.indexOf(record) == -1){
this.modified.push(record);
}
this.fireEvent('update', this, record, Ext.data.Record.EDIT);//removed
},
So the miracle happens and store.getModifiedRecords()
returns your record in array included.
Now talk about problem. So the problem is that markDirty()
looks like this(from official docs):
markDirty: function(){
this.dirty = true;
if(!this.modified){
this.modified = {};
}
this.fields.each(function(f) {
this.modified[f.name] = this.data[f.name];
},this);
}
and here is not anything that would call afterEdit
or something like this to make your records dirty on a store level(well as you see it becomes dirty only on a record level).
Maybe someone say it is meant to be used only on a record level but markDirty doc description says:
Marking a record dirty causes the phantom to be returned by Ext.data.Store.getModifiedRecords ..
So it should have worked(but didn't).