0
votes

I am using extjs 3.4 and I want to make records to appear when I use getModifiedRecords.

dtl.store.getAt(i).markDirty(); This is what I did and when I console.log() it I can see dirty:true and also modified:{idStyle: "TEST-4", idStyleDtl: 2052, color: 6, colorNm: "BLACK", s1: 0, …}

It clearly shows it has been modified and there's dirty flag but when I do ojbStore.getModifiedRecords() it returns just empty [ ]. I don't understand why it won't return the modified records.. Is there any other condition I need to change?

Thanks

1

1 Answers

0
votes

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).