View Full Version : Maintaining dirty state of editable data model

30 Jan 2007, 11:41 PM
I'm able to listen to the cellupdated event on an EditableGrid's data model. However, I'd like to encapsulate maintenance of the dirty state of the model into the DataModel itself, so I can just call something like, grid.getDataModel().isDirty().
I imagine I'm going to have to hot-rod AbstractDataModel to maintain its own dirty state. Does this sound like a sensible approach? Has anyone else done something similar? Any guidance would be much appreciated.

31 Jan 2007, 12:35 AM
If all you want is a single isDirty flag (as opposed to a flag for each cell), then it's a piece of cake to add this.


In the handler you are passed:

# this : DataModel
# rowIndex : Number
# columnIndex : Number

So you can set a boolean property in the DataModel to true. You could use YAHOO.extendX to add iisDirty() to return tat boolean, but you don't have to - you can just access it directly.

Even if you wanted a flag for each cell, it would eb quite easy to add like this.

14 Sep 2007, 10:45 PM
Hi, I have a check/Uncheck field in Editable Grid.
I want this field , not to contribute in the dirty state of Data Store. How can I do that??

14 Sep 2007, 10:46 PM
OR How can I sent the dirty state of a column to always FALSE??

14 Sep 2007, 10:46 PM
How can I set the dirty state of a column to always false??

14 Sep 2007, 11:07 PM
Maybe add a listener for this event: http://extjs.com/deploy/ext/docs/output/Ext.grid.EditorGrid.html#event-afteredit

That fires after the Record that backs the Grid row has been updated.

The Record contains an Array called modified which contains the field names that are modified.

You could use

delete myRecord.modified[myFieldName];

Or you could use http://extjs.com/deploy/ext/docs/output/Ext.grid.EditorGrid.html#event-validateedit

Which fires before the Record is changed, so you could react to the event in your own code, and return false to veto the edit.

15 Sep 2007, 1:10 AM
I did it but it still shows the whole record dirty.

15 Sep 2007, 5:05 AM
You can just clear the flag yourself.

17 Sep 2007, 2:15 AM
I did it. It works :D
Thank you ANIMAL !