keep text color in column when clicking sort

Hello~

When I test sample code in stackblitz

How could I keep my customized color in text of header( Customer  Name)

after I click sort?


Before sort

initial.JPG


After sort

clicksort.JPG


4 Replies

VB Vinitha Balasubramanian Syncfusion Team May 16, 2022 05:23 PM UTC

Hi Customer ,


Greetings from the Syncfusion support .


Currently we are working on your query and we will update further details on May 18,2022.

until then we appreciate your patience


Regards,

Vinitha Balasubramanian



VB Vinitha Balasubramanian Syncfusion Team May 17, 2022 03:12 PM UTC

Hi Sphere ,


Thanks for your patience .


Query : Keeps text color in column when clicking sorting


Based on your query, you want to change the style to the specific column called "Customer Name". We accomplished this using the headerCellInfo event, and we are overriding the default CSS in the special class for sorting ("color:black") .


For your convenience, we have attached code sample for your reference.


[in html]

<ejs-grid

    class="sortingenabled"

    id="Grid"

    [dataSource]="data"

    actionBegin="actionBegin"

    allowPaging="true"

    allowSorting="true"

    [sortSettings]="initialSort"

    [pageSettings]="pageSettings"

    (headerCellInfo)="headerCellInfo($event)"

  >

 

[in ts]

  headerCellInfo(args) {

    if (args.cell.column.field === 'CustomerName') {

      var classData = args.node;

      classData.classList.add('Customised');

    }

  }

 

[in css]

.e-headercell.Customised.e-mousepointer {

  colorrgb(22715235);

  background-colorblack !important;

  font-family'Bell MT';

}

 

.e-grid th.e-headercell[aria-sort='ascending'.e-headertext {

  colorrgb(22715235);

}

 

.e-grid th.e-headercell[aria-sort='descending'.e-headertext {

  colorrgb(22715235);

}


Sample link : https://stackblitz.com/edit/angular-sgjwkg-23ashu?file=app.component.css,app.component.ts,app.component.html,main.ts


Documentation link : https://ej2.syncfusion.com/angular/documentation/api/grid/#headercellinfo


Kindly get back to us if you need further assistance on this.


Regards,

Vinitha Balasubramanian



SP Sphere May 30, 2022 02:34 AM UTC

Thanks for help~~

It works for me 



PS Pavithra Subramaniyam Syncfusion Team May 31, 2022 08:54 AM UTC

Hi Sphere,


Welcome! We are glad to hear that the provided solution helped you.


Please get back to us if you need further assistance on this.


Regards,

Pavithra S


Loader.
Up arrow icon