ActionOnLostFocus not working

4 posts, 0 answers
  1. Denis
    Denis avatar
    4 posts
    Member since:
    Dec 2007

    Posted 16 Jul 2012 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Jul 2012 Link to this post

    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.

  3. Denis
    Denis avatar
    4 posts
    Member since:
    Dec 2007

    Posted 17 Jul 2012 Link to this post

    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
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Jul 2012 Link to this post

    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.

Back to Top