Hi there
I have a dialog with a Cancel button on it to allow the user to abort editing. The dialog contains a few standard controls and a grid. For the grid, I set the UpdateMode to UpdateMode.OnUpdate. Based on the documentation, I expected that I would have to execute a command once the dialog's OK button is clicked in order to udpate the underlying data items. However, as soon as an edited cell leaves EditMode, the update is immediately commited to the underlying DataItem.
OnUpdate: The DataSource is updated only when the DataPresenterCommands.CommitChangesToAllRecords or DataPresenterCommands.CommitChangesToActiveRecord command is executed.
Am I missing something or doesn't this work as supposed?
Cheers
Philipp
Hi Philipp,
What kind of data source are you using?
This feature will only work if the underlying data items implement IEditableObject interface. Essentially OnUpdate is meant to prevent the DataGrid from calling IEditableObject.EndEdit on the data items that are modified until you explicitly do so via CommitChangesToAllRecords commands. So it will only work if the underlying data items support .NET IEditableObject interface. Some of the data sources that support this interface are DataTable, DataSets, DataViews, UltraDataSource. If you have a custom data source, you can implement IEditableObject on your data objects. Essentially objects that implement IEditableObject are meant to hold original value as well as the newly modified value and only commit the new value when IEditableObject.EndEdit is called.
Sandip