Handling GridViewEditAction.Cancel

3 posts, 0 answers
  1. Brian Sayatovic
    Brian Sayatovic avatar
    91 posts
    Member since:
    Nov 2009

    Posted 21 Feb 2012 Link to this post

    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. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 Feb 2012 Link to this post

    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 >>
  3. Brian Sayatovic
    Brian Sayatovic avatar
    91 posts
    Member since:
    Nov 2009

    Posted 22 Feb 2012 Link to this post

    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.
Back to Top