Cancel Edit On LostFocus
The RadGridView control exposes an ActionOnLostFocus property which allows you to control what happens when the control loses the focus.
The ActionOnLostFocus enumeration has three possible values:
- CancelEdit: When the focus of a field in edit mode is lost, its edit mode will be canceled.
- CommitEdit: When the focus of a field in edit mode is lost, its contents will be validated.
- None: When the focus of an element is lost, no specific action will be taken.
The default value of the property is CommitEdit meaning that all changes will be commited when the control loses focus.
Let's say, for example, that you want to have two buttons outside of your RadGridView which are bound to the CommitEdit and CancelRowEdit commands.
Example 1: Buttons Bound to RadGridView Commands
<Button Content="Confirm"
Command="telerik:RadGridViewCommands.CommitEdit"
CommandTarget="{Binding ElementName=GridView}"/>
<Button Content="Cancel"
Command="telerik:RadGridViewCommands.CancelRowEdit"
CommandTarget="{Binding ElementName=GridView}"/>
Figure 1: RadGridView with default ActionOnLostFocus
To overcome this, you can simply set the ActionOnLostFocus property to None.
Example 2: Set ActionOnLostFocus to None
<telerik:RadGridView ActionOnLostFocus="None" ...>