We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Datagrid sort column header color styling

Syncfusion.png Hi,

Please advice 

I want to adjus the column header of the ascending or descending order of data in terms of:

Font & font color

Thank you

Ragy


4 Replies

BL Balamurugan Lakshmanan Syncfusion Team February 10, 2023 01:41 PM UTC

Hi  AFICO ,


Greeting from Syncfusion support.


We understand that you're trying to adjust the column header of the ascending or descending order of data in terms of: Font & font color. So we suggest you to use the below highlighted codes at your end .


<SfGrid  DataSource="@Orders" AllowSorting="true" Height="270">

    <GridEvents OnActionBegin="ActionBeginHandler" TValue="Order"></GridEvents>

<HeaderTemplate>

                @if (flag)

                {

                    <div>

                        <span style="color:red"> Emp ID</span>                       

                    </div>                 

                }

                else if(flagdes)

                {

                    <div>

                        <span style="color:chartreuse"> Emp ID</span>

                    </div>

                }

                else

                {

                    <div>

                        <span> Emp ID</span>

                    </div>

                }

            </HeaderTemplate>

<SfGrid>

 

@code

{

public void ActionBeginHandler(ActionEventArgs<Order> args)

    {

        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Sorting)

        {

            if (args.Direction == Syncfusion.Blazor.Grids.SortDirection.Ascending)

            {

                flag = true;

            }

            else if (args.Direction == Syncfusion.Blazor.Grids.SortDirection.Descending)

            {

                flagdes = true;

                flag = false;

            }

        }

       

 

    }

}


We have also included an sample as per your requirement. Kindly check the below attached sample and code snippet for your reference.


Please get back to us if you have further queries.


Regards,

Bala.


Attachment: BlazorApp2_74398a3b.zip


AF AFICO Filters replied to Balamurugan Lakshmanan February 12, 2023 08:49 AM UTC

Thank you 

Ragy



NP Naveen Palanivel Syncfusion Team February 14, 2023 03:10 AM UTC

Hi AFICO,


Welcome,


Please get back to us if you need further assistance.


Regards,

Naveen Palanivel



SG Suganya Gopinath Syncfusion Team February 15, 2023 05:12 PM UTC

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.




Loader.
Live Chat Icon For mobile
Up arrow icon