Color Header

How do i make different color header in below pivot table


What will be my css. It seems whatever i applied it applies to all the 3 rows in header and also as you can see fonts are selectively White.


3 Replies 1 reply marked as answer

MM Manikandan Murugesan Syncfusion Team January 12, 2022 02:34 PM UTC

Hi Parth Rawal, 
 
Using the "headerCellInfo" event, you can apply a different background color to column headers based on their level. Please see the code below for an example. 
Code Example: 
  headerCellInfo(args) { 
    (this.pivotObj.renderModule as any).columnCellBoundEvent(args); 
    //triggers every time for header cell while rendering 
    if (args.cell && args.cell.column && args.cell.column.customAttributes) { 
      args.node.classList.add( 
        'level' + args.cell.column.customAttributes.cell.rowIndex 
      ); 
    } 
  } 
 
  enginePopulated(args) { 
    this.pivotObj.grid.headerCellInfo = this.headerCellInfo.bind(this); 
  } 
 
Meanwhile, we have prepared a sample for your reference. Please find it from below link. 

 
For more details about the “headerCellInfo” event, please refer the document link below. 
 
Please let us know if you have any concerns. 
 
Regards, 
Manikandan 


Marked as answer

PD PDev January 17, 2022 10:03 AM UTC

Hi

Is there a way to change the font color, because in example above i could not change the font color.  and also when collapsing and expand. it changes font color from white to black again



MM Manikandan Murugesan Syncfusion Team January 17, 2022 01:07 PM UTC

Hi Parth Rawal, 

Please use the CSS below to change the font color for column header cells based on the header level. 

Code Example: 
    <style> 
      .e-pivotview .e-columnsheader.level0, 
      .e-pivotview .e-columnsheader.level0 .e-cellvalue, 
      .e-pivotview .e-columnsheader.level0 .e-stackedheadercelldiv, 
      .e-pivotview .e-columnsheader.level0 .e-headertext { 
        background-coloraquamarine !important; 
        colorwhite !important; 
      } 
      .e-pivotview .e-columnsheader.level1, 
      .e-pivotview .e-columnsheader.level1 .e-cellvalue, 
      .e-pivotview .e-columnsheader.level1 .e-stackedheadercelldiv, 
      .e-pivotview .e-columnsheader.level1 .e-headertext { 
        background-colorthistle !important; 
        colorwhite !important; 
      } 
      .e-pivotview .e-columnsheader.level2, 
      .e-pivotview .e-columnsheader.level2 .e-cellvalue, 
      .e-pivotview .e-columnsheader.level2 .e-stackedheadercelldiv, 
      .e-pivotview .e-columnsheader.level2 .e-headertext { 
        background-colorlightblue !important; 
        colorwhite !important; 
      } 
    </style> 

Meanwhile, we have prepared a sample for your reference. Please find it from below link. 

 
Please let us know if you have any concerns. 

Regards, 
Manikandan 


Loader.
Up arrow icon