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

Handling GridViewEditAction.Cancel

2 Answers 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brian Sayatovic
Top achievements
Rank 1
Brian Sayatovic asked on 21 Feb 2012, 07:43 PM
When a row is being edited, the new values entered into the cells are being directly bound to my item.  What is the best way to handle the Cancel action to restore the item to what it once was?

The GridViewRowEditEndedEventArgs contains the old values, so I could in theory set them back into the item.  My item also has Backup/Restore functionality intended to support this style of editing.  In either case, though, the EventArgs' EditedItem is null (for an existing item being edited).  I'm considerign getting the Item property of the EventArgs' Row, but this is starting to feel more and more wrong.

What is the best way to restore an item to its original state when cancelling a row edit?

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 22 Feb 2012, 10:00 AM
Hi,

 You should use IEditableObject to achieve your goal. 

Regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Brian Sayatovic
Top achievements
Rank 1
answered on 22 Feb 2012, 02:47 PM
I had not come across that interface before, so thank you for pointing this out.

I've implemented this and it's working very well.  The attached properties for commands I had created to allow MVVM'ing the RadGridView's edit events are now unnecessary.

You would do well to add a more direct mention of leveraging the IEditableObject in your row/cell editing documentation for RadGridView.
Tags
GridView
Asked by
Brian Sayatovic
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Brian Sayatovic
Top achievements
Rank 1
Share this question
or