PDA

View Full Version : Mark a model as clean



harrypottar
10 Apr 2012, 6:28 AM
I have a store attached to a grid, I turned off auto sync as when I modify records I only want to update the one record not all the records. (this is all working apart from clearing the dirty flag)

In my controller I have


init: function() {
this.control({
'useraddressbook gridpanel' :{
edit: this.UpDateRecord,
},
});
},

UpDateRecord: function(editor, e) {
//get the record the user as click in the grid
var rec = e.record;
if (!rec.dirty) return true;
if (!rec.isValid()) return true;
Ext.Ajax.request({
waitMsg: 'Please Wait',
url: '/my/php/script',
params: {
action: "updatedbuseremails",
emailid: rec.get('EmailID'),
email: rec.get('email'),
name: rec.get('name'),
},
success:function(response,options){
rec.dirty = false;//read only :(
if (ConfigObj.debugiomail) {
console.log("Debug: Updated Record " + rec.get('name') + " (" + rec.get('email') + ")" )
}
}
})
}


This all works, but when I return I want to mark the record clean? I do not see a method for that record.dirty is read only

TIA
Harry

scottmartin
10 Apr 2012, 6:42 AM
Harry,

You can try the following:



var rec = this.form.getRecord();
rec.commit(); // removes the dirty marker


Regards,
Scott.

harrypottar
10 Apr 2012, 6:44 AM
Thanks that worked.