Datagrid change row Color based on value in row


#1

Hello,

how could I change the background or fontcolor color of a row based on a value in that row?

I have tried this


and this works ok for coloring a cell... but would it be possible to color a row ?


#2

Hi,

Yes, you can do that:

Page Load execute action:

this.grid0.dataTable.rowStyleClass = (data, index) => {
   return data.Id >= 3 ? 'class1' : 'class2';
}

styles.css

.class1 td {
  background-color: red;
}


.class2 td {
  background-color: blue;
}


#3

OK, this works... thank you