Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeNG Treetable: Alternating row colors

I am using primeNG tree table for angular4 and I am trying to style it that odd and even rows has different colors. I am able to do it but only for root rows, when you expand the rows it will get the row color of it's parent.

I also checked the markup produced in html but there's no class that indicates if a row is odd or even.

How exactly do we do it?

like image 590
Emmanuel Campos Avatar asked Feb 01 '26 05:02

Emmanuel Campos


1 Answers

A year has passed and in the new version it's as easy as using the normal nth-child on the rows:

.ui-treetable-table {
  tbody {
    tr:nth-child(even) {
      background: #e9ecef;
    }
  }
}
like image 195
Scuba Kay Avatar answered Feb 02 '26 22:02

Scuba Kay