What's the recommended approach for cancelling edits made to existing and new rows in a XamDataGrid? My XamDataGrid is bound to a DataView. In the code below the SelectedTab.Records is a DataView.
This is the code I have that seems to work for existing rows, but not for changes made to the add row.
foreach (DataRowView view in SelectedTab.Records) {
if(view.IsEdit) { view.Row.RejectChanges(); view.Row.AcceptChanges(); view.Row.BeginEdit(); } view.BeginEdit(); }
When called on the add row I get the following exception -
An exception of type 'System.Data.RowNotInTableException' occurred in NCS.MIDP.exe but was not handled in user code
Additional information: This row has been removed from a table and does not have any data. BeginEdit() will allow creation of new data in this row.
Hi,
This issue seems to have cropped up again for us and I was looking into the documentation for the DataPresenterCommands and none of them seem to actually do what we want. The goal is to undo ALL edits that have not been committed on the grid. It sounds like DiscardChangesToAllRecords should do that, but the documentation and description imply that it does the exact same thing as DiscardChangesToActiveRecord. Sure enough, it doesn't actually seem to undo the changes for the records in the grid. Additionally, EndEditModeAndDiscardChanges seems to work, but only for the specific cell that was in the process of being edited.
Hi Darlene,
I am really glad to hear you have this resolved.
Thank you for using Infragistics components.
I ended up using DiscardChangesToAllRecords but that fixed it for me.
Thanks.
Hello Darlene,
I’ve been looking into this and I can suggest discarding the record’s changes with the ExecuteCommand method of the XamDataGrid like so:
xamDataGrid1.ExecuteCommand(DataPresenterCommands.DiscardChangesToActiveRecord);
Please let me know, if you require any further assistance on the matter.