Change the position of the arrow (sort) in the header of the grid.

5 posts, 1 answers
  1. Eusebio
    Eusebio avatar
    21 posts
    Member since:
    Aug 2020

    Posted 09 Sep Link to this post

    Hello,

    I would like to change the position of the header arrow when sorting the column in a RadGridView. By default it appears above the column text, but I want it to be positioned to the RIGHT of that text.

    I use VS2019 with the theme "Office2013Light".

    Regards,

  2. Nadya
    Admin
    Nadya avatar
    389 posts

    Posted 14 Sep Link to this post

    Hello, Eusebio,

    If you want to position the arrow button when sorting to the right of the text you can change its Alignment property in the ViewCellFormatting event. Please refer to the following code snippet:

    private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
       var headerCell= e.CellElement as GridHeaderCellElement;
        if (headerCell != null)
        {
            headerCell.Arrow.Alignment = ContentAlignment.MiddleRight;
        }
        else
        {
            headerCell.Arrow.ResetValue(LightVisualElement.AlignmentProperty, ValueResetFlags.Local);
        }
    }
    

    I hope this helps. Should you have other question do not hesitate to contact me.

    Regards,
    Nadya
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

  3. Eusebio
    Eusebio avatar
    21 posts
    Member since:
    Aug 2020

    Posted 16 Sep in reply to Nadya Link to this post

    Thanks Nadya,

    It work if "headerCell" isn't null, else error.

    Regards.

  4. Answer
    Nadya
    Admin
    Nadya avatar
    389 posts

    Posted 16 Sep Link to this post

    Hello, Eusebio,

    You can use the following code snippet instead:

    private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        if (e.CellElement is GridHeaderCellElement)
        {
            var headerCell = e.CellElement as GridHeaderCellElement;
            headerCell.Arrow.Alignment = ContentAlignment.MiddleRight;
        }
    }

    Let me know if you need further assistance.

    Regards,
    Nadya
    Progress Telerik

    Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

  5. Eusebio
    Eusebio avatar
    21 posts
    Member since:
    Aug 2020

    Posted 16 Sep in reply to Nadya Link to this post

    Hi Nadya,

    Yes, it work.

     

    Thank you very much.

     

     

     

     

     

Back to Top