PDA

View Full Version : Editorgrid dirty flag



MarcoMalar
11 Jan 2012, 11:44 PM
When changing a value in the editorgrid a dirty flag will show that the value has been changed.
When changing back the value to the original value (last committed) , the dirty flag is still there.
Is this a bug?
I think the dirty flag should be set to false automatically when the last committed value is entered again.

Because this is not the actual standard behaviour, i will have to compare the entered value with the last committed value and remove the dirty flag programmatically.
My problem: I searched the API but I dont't find the method or property to get the last committed value of the grids cell.
Nevertheless it must be held somewhere, because when using the reject or reset methods of store or record, the value is set back to the last committed one.
In the afteredit method of the editorgrid the e.originalValue is the last one that was set and not the last committed one.

Please advise me to the right method or property to obtain the last committed value.

mitchellsimoens
12 Jan 2012, 7:48 AM
If you change it and don't want a record to be dirty, you need to execute commit() on the record.

MarcoMalar
12 Jan 2012, 11:38 PM
I want to have the dirty flag if the value is another than the last commited one. But i want the dirty flag to be removed if the user changes the value back to the last committed one.
This should be the default behaviour in my opinion.

How do I get the last commited or last loaded value of the cell to be able to compare it with the actually entered value?

MarcoMalar
13 Jan 2012, 12:21 AM
Here is my actual workaround:
(for only one editable column)


'gridAfterEdit' : function(e) {
var value = new String(e.record.get(e.field));
e.record.reject();
var originalLoadedValue = new String(e.record.get(e.field));
if ($.trim(value) != originalLoadedValue)
{
e.record.set(e.field, value);
}
}


===>


I would prefer a property or method to get the last commited or loaded value directly without having to reject and then to set the entered value again.
I would appreciate this to be the default behaviour of the editorgrid.The actual behaviour is not what you expect because the record will remain dirty even if the value is exactly the same as the last committed one.