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

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

4 Answers 355 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eusebio
Top achievements
Rank 1
Veteran
Eusebio asked on 09 Sep 2020, 10:33 AM
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,

4 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 14 Sep 2020, 08:40 AM

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).

0
Eusebio
Top achievements
Rank 1
Veteran
answered on 16 Sep 2020, 10:26 AM
Thanks Nadya,

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

Regards.

0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 16 Sep 2020, 01:25 PM

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).

0
Eusebio
Top achievements
Rank 1
Veteran
answered on 16 Sep 2020, 02:40 PM

Hi Nadya,

Yes, it work.

 

Thank you very much.

 

 

 

 

 

Tags
GridView
Asked by
Eusebio
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Eusebio
Top achievements
Rank 1
Veteran
Share this question
or