PDA

View Full Version : dirty property when updaterecord called



martinc
7 Jul 2011, 1:09 PM
when calling updateRecord from Ext.form.FormPanel my model was always getting marked dirty, even if the data values had not changed. I've tried to make this smarter by applying a small change to the function so it now looks as below:


updateRecord: function(instance, enabled) {
var fields, values, name;
if(instance && (fields = instance.fields)){
values = this.getValues(enabled);
for (name in values) {
if(values.hasOwnProperty(name) && fields.containsKey(name)){
if(instance.data[name] != values[name]){
instance.set(name, values[name]);
}
}
}
}
return this;
}


this means that if I call updateRecord to read form fields into my model, it only marks the model as dirty if the values read in differ to what was already in the model. Any chance of incorporating this change?

p.s. posted this to discussion but no interest there. is this a bug? also, 2 or 3 '=' syntax? perhaps this could be a config option