This is a migrated thread and some comments may be shown as answers.

Implementation of CancelEdit (2011.2.0920)

0 Answers 26 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Heiko
Top achievements
Rank 1
Veteran
Heiko asked on 23 Dec 2011, 12:05 PM
The documentation on MSDN says about CancelEdit:

CancelEdit sets CurrentEditItem to null and causes the collection view to exit the edit state. If CanCancelEdit is true, CancelEdit also restores the original values of the edited object.

This means: first set CurrentEditItem to null, then if possible restore original values. The implementation in QueryableCollectionView.Editing.cs is slightly different because CurrentEditItem is only set to null if it is an IEditableObject otherwise it throws an exception. In my opinion this is not correct. Of course CancelEdit should only be called on the CurrentEditItem if it is an IEditableObject, but setting CurrentEditItem to null should always be called! So the corrected code must be:

if (this.CanCancelEdit)
{
   CancelEditItem(this.CurrentEditItem);
}
this.CurrentEditItem = null;

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Heiko
Top achievements
Rank 1
Veteran
Share this question
or