Search code examples
angularcsstypescriptngx-datatable

unable to set separate colors for Odd and even rows


here what i am trying i am displaying a dynamically generated table using ngx-datatable but i am trying to display is for odd rows i want to display one color and on for even row i tried applying the nth element &

body .datatable-body-row .datatable-row-even {
    background: orange;
}



body datatable-body-row .datatable-row-odd {
    background: aqua;
   } 



   .ngx-datatable.bootstrap .datatable-body .datatable-body-row.datatable-row-even {
    background-color: red;
}

i tried all these to set row colors for odd or even rows but these styles are not applying


Solution

  • Try using the class names directly as below should work:

    .datatable-row-even {
        background-color: red;
    }
    
    .datatable-row-odd {
        background-color: blue;
    } 
    

    Its working for me: Stackblitz Demo