RadGridView - how to bypass BeginEdit & EndEdit

3 posts, 1 answers
  1. Michael
    Michael avatar
    21 posts
    Member since:
    Apr 2011

    Posted 07 Sep 2011 Link to this post

    I have a usercontrol with a master record (Project) and a radgridview with details (ProjectItems). Project & ProjectItems are observable collections (the details gridview is populated using LINQ Lamda Where of the master project ID). The projectitems are quite complicated.
    I would like to have 1 edit button at the Project level that activates the BeginEdit IEditableObject Member on the Project record and the BeginEdit IEditableObject Members on ALL the related ProjectItems.
    Then the user will be able to Commit or Cancel ALL the changes for the project and associated items by pressing a Save or Cancel button which will in turn run the EndEdit or CancelEdit IEditableObject Members on the Project and ALL related Project Items.
    The problem I have is that the radgridview automatically calls the BeginEdit, EndEdit & CancelEdit IEditableObject Members so when the user edits an item as soon as they move off the row the change is comitted, pressing the cancel button has no effect.

    Is there any way to tell the RadGridView NOT to automatically process the BeginEdit, EndEdit & CancelEdit IEditableObject Members on the underlying data? 
      
  2. Answer
    Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 12 Sep 2011 Link to this post

    Hi Michael,

    Indeed RadGridView calls IEditableObject interface methods automatically based on the action taken over the business object and there is no way to stop these calls. Of course you could "mark" your data item and process EndEdit() or CancelEdit() accordingly.

    When I read your ticket I feel that you don't have a problem with IEditableObject interface, but with a default RadGridView setting. RadGridView has a property called ActionOnLostFocus which by default is set to "CommitEdit", therefore when you click on a "Cancel edit" button - RadGridView loses focus commits the edit and then "Cancel edit" button click event handler is executed.
    I'm almost sure that when you set ActionOnLostFocus property to "None" the problem will be solved.

    Note: Be aware that you should take care for any possible pending edit.

    Let me know if this doesn't help.

    All the best,
    Nedyalko Nikolov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Michael
    Michael avatar
    21 posts
    Member since:
    Apr 2011

    Posted 12 Sep 2011 Link to this post

    Thanks, I wasn't aware of the ActionOnLostFocus property, that will help, I will make sure that I action any pending edits, thak you for the warning.
Back to Top