Block return next row after cell editing

11 posts, 0 answers
  1. Valentin
    Valentin avatar
    153 posts
    Member since:
    Mar 2016

    Posted 12 Dec 2016 Link to this post

    Hello Telerik,

    I'm working with a RadGridView in WPF, and actually, I'm testing for the cells editing.

     

    When the user pressed 'Enter' to validate his data, the focus is automaticaly did on the next row. I searched in your Controls Examples but I didn't found the solution.

    => How can I to do that the focus should do on the cell was been edited ?

     

    Thank you very much.

    Valentin.

  2. Valentin
    Valentin avatar
    153 posts
    Member since:
    Mar 2016

    Posted 13 Dec 2016 in reply to Valentin Link to this post

    Hello,

     

    I have 2 others questions about RadGridView (I can't update the post title) :

     

    1- It's possible for a grid to set ActionOnLostFocus="CancelEdit". But if the user is editing a cell and he clicks on an other cell, the thread goes to _CellValidating event (where I check the correct format of cells user values) and he returns an error. I want to know if is it possible to set an 'ActionOnLostFocus' for a cell ?

    (Exemple width attached 'actiononlostfocus' file)

    2- I created a Style for gridView cells :

    <Style x:Key="cellStyle" TargetType="telerik:GridViewCell">
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
    </Style>

    When I applied it on my gridColumns, the TextBox (or Textblock) width is set to Auto and I didn't found where can I fix it to the column width.

    (Exemple width attached 'witdh_1' & 'width_2' files)

     

    Can you help me ?

    Thank you.

  3. Valentin
    Valentin avatar
    153 posts
    Member since:
    Mar 2016

    Posted 28 Dec 2016 Link to this post

    Up :)
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1218 posts

    Posted 30 Dec 2016 Link to this post

    Hello,

    Currently ActionOnLostFocus is supported only on Row and GridView level and not for separate cells only. As for modifying the default navigation behavior after completing edit, you can define a custom CommandsProvider that controls the logic that is executed on "enter".
    As for the inquiry about the CellStyle, can you please confirm what the desired results would be? Stretched textblock/textbox with centered text, am I right?

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Valentin
    Valentin avatar
    153 posts
    Member since:
    Mar 2016

    Posted 30 Dec 2016 in reply to Ivan Ivanov Link to this post

    Hello Ivan,

    Thank you for your answer.

     

    Yes, the goal is diplaying stretched textblock/textbox with centered text and unresizable textblock/textbox.

    Actually, when the cell is in editing mode, and my custom style is applied, the textblock/textbox width is automaticly adjusted.

     

    And, do you have any idea for the first question ?

     

    Thank you very much.

     

    Valentin.

  6. Valentin
    Valentin avatar
    153 posts
    Member since:
    Mar 2016

    Posted 30 Dec 2016 in reply to Valentin Link to this post

    Sorry, the answer for the first question is in your answer !

     

    So, I don't know how can I apply an override method for a 'ActionOnLostFocus' cell with the CustomKeybordCommandProvider ?

     

    Thank you.

  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1218 posts

    Posted 30 Dec 2016 Link to this post

    Hi,

    You want to prevent RadGridView from starting edit of next row, when "Enter" is hit, am I right? The command provider mechanism of RadGridView enqueues a sequence of commands that should be executed when the appropriate keyboard input occurs. The default sequence when enter is hit contains the MoveNext command, which you can skip, preventing the focus to move the first editable cell of the next row. However, I am not entirely sure whether you target to cancel the edit if there are validation errors?
    As for the text alignment question, you can use the TextAlignment property of GridViewBoundColumnBase, setting it to 'center'. I believe that it should do the trick, without the need of having custom styles.

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  8. Valentin
    Valentin avatar
    153 posts
    Member since:
    Mar 2016

    Posted 02 Jan 2017 in reply to Ivan Ivanov Link to this post

    Hello Ivan,

     

    I found the solution for the 'Enter' key pressed with command provider like you told me. But, I don't know how use the KeybordCommandProvider for 'ActionOnLostFocus' with Mouse ?

    Next, TextAlignment="Center" for each telerik:GridViewDataColumn is working find !

     

    Thank you.

    Valentin.

     

  9. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1218 posts

    Posted 02 Jan 2017 Link to this post

    Hi,

    You can try calling CancelEdit on CellValidated, to mimic ActionOnLostFocus="CancelEdit", on cell level. It should be something like this:
    private void OnCellValidated(object sender, GridViewCellValidatedEventArgs e)
    {
        if (e.ValidationResult.ErrorMessage != null)
        {
            clubsGrid.CancelEdit();
        }
    }


    Regards,
    Ivan Ivanov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  10. Valentin
    Valentin avatar
    153 posts
    Member since:
    Mar 2016

    Posted 03 Jan 2017 in reply to Ivan Ivanov Link to this post

    Hello,

     

    Thanks for you'r help but the process doesn't enter in my gridViewVariables_CellValidated and so it doesn't working find.

     

    I tried to set a custom Cell.LostFocus Event like this :

    private void gridViewSystemesDeCollectes_CellLoaded(object sender, CellEventArgs e)
    {
        if (e.Cell is GridViewCell)
            e.Cell.LostFocus += new RoutedEventHandler(this.OnCellLostFocus);
    }
     
    private void OnCellLostFocus(object sender, RoutedEventArgs e)
    {
        GridViewCell cell = sender as GridViewCell;
     
        if (cell != null)
            cell.IsInEditMode = false;
    }

    But IsInEditMode Cell Property is not the find property to CancelEditMode.

     

    Valentin.

  11. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1218 posts

    Posted 06 Jan 2017 Link to this post

    Hello,

    If you plan to stick with this approach, you can use the RowInEditMode property to check whether the target cell is a child of the edited row:
    void OnCellLoaded(object sender, Telerik.Windows.Controls.GridView.CellEventArgs e)
    {
         . . .
        if (e.Cell.ParentRow == gridView.RowInEditMode)
        {
            gridView.CancelEdit();
        }
    }


    Regards,
    Ivan Ivanov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top