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

ActionOnLostFocus not working

3 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Denis
Top achievements
Rank 1
Denis asked on 16 Jul 2012, 02:57 PM
Hi,

i have a problem with the ActionOnLostFocus property of the RadGridView control.
I am using RadGridCommands to edit rows in my Grid. There are an edit, save and cancel button and they work fine. But when a row is in edit mode and it loses focus, the event arguments show that the EditAction is set to commit, no matter what I set to the ActionOnLostFocus property of the GridView.

Here is my XAML:
...
<telerik:RadButton Width="150" Content="Edit Permission" Margin="0,0,5,0"
  Command="telerikGrid:RadGridViewCommands.BeginEdit" CommandTarget="{Binding ElementName=RoleGrid}" />
            <telerik:RadButton Width="150" Content="Save insert/edit" Margin="0,0,5,0"
  Command="telerikGrid:RadGridViewCommands.CommitEdit" CommandTarget="{Binding ElementName=RoleGrid}" />
            <telerik:RadButton Width="150" Content="Cancel insert/edit"
  Command="telerikGrid:RadGridViewCommands.CancelRowEdit" CommandTarget="{Binding ElementName=RoleGrid}"  />
...
<telerik:RadGridView x:Name="RoleGrid" Grid.Row="1" Margin="5" EditTriggers="None" ActionOnLostFocus="CancelEdit"
                             ItemsSource="{Binding RolePermissions}" SelectionMode="Single"
                             SelectedItem="{Binding SelectedPermission, Mode=TwoWay}"
                             CanUserSortColumns="True" CanUserInsertRows="True" CanUserDeleteRows="True" 
                             AutoGenerateColumns="false" ShowGroupPanel="False" CanUserReorderColumns="False">
...
I am using MVVM light and binding the event to a command, but it´s the same with a simple event handler.
The code looks like this:

private void UpdateRowData(GridViewRowEditEndedEventArgs e)
{
            if (e.EditAction == GridViewEditAction.Commit)
            {
//save data
    }
            else
//cancel action
}

Is this a known issue? Did I miss anything? The version I am using is 2012.1.215.1050.

Best Regards

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 17 Jul 2012, 11:51 AM
Hello,

 I have tested the described scenario. At my end when the RowEditEnded event is raised, the value for the EditAction is "Cancel". I have attached the test application for a reference.

Would you please let me know how I could reproduce the issue on the test project?

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Denis
Top achievements
Rank 1
answered on 17 Jul 2012, 12:09 PM
Hi,

thank you for your answer. I downloaded your example, rebuilt it without any changes and started it. I got the same result. When I click on a cell to edit it and then click on another row, the EditAction is set to Commit.

I attached a screenshot. 

Best Regards
0
Dimitrina
Telerik team
answered on 17 Jul 2012, 12:49 PM
Hi,

 Thank you for the remark. Actually I have tested the behaviour when the GridView loses focus. For example  when I click on a Button outside of the GridView. The EditAction is Cancel when the GridView loses focus, not when the next row is selected. In that case the EditAction is Commit by design.

I would suggest you to subscribe for the RowValidating event instead and try to implement your logic there. Please note that you could cancel the edit using the CancelEdit() event of the RadGridView.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Denis
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Denis
Top achievements
Rank 1
Share this question
or