PDA

View Full Version : Commit only specific fields on a model



andreas-spindler
18 Feb 2014, 6:50 AM
A simplified example of what I want to do: I'd like to do time tracking inside a grid with columns for startTime, stopTime and duration. The value for duration column is calculated as stopTime - startTime inside the update event handler of the store. As I don't want the dirty triangle on the duration cell I do a record.commit(false,['duration']. But this commits also the other two fields which I don't want.

So, is there a way to commit only specific fields of a model or to set the value without marking this field as dirty?

Edit: To be more specific: Is there a nicer way than just setting record.data.duration directly?

brian428
18 Feb 2014, 9:15 PM
As far as I know, there's no built-in way to partially commit changes. You can set it directly (as you said), but the only other option would probably be override(s) or a custom Model subclass to wrap up your partial commit logic.