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

RadGridView - how to bypass BeginEdit & EndEdit

2 Answers 325 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 07 Sep 2011, 12:21 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 12 Sep 2011, 02:55 PM
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 >>

0
Michael
Top achievements
Rank 1
answered on 12 Sep 2011, 03:52 PM
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.
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or