Change Colour based on selected value | Change color based on value | Change Color field color
Change Colour based on selected value | Change color based on value | Change Color field color
aungkohein
Posts: 38Questions: 5Answers: 0
Hi guys!
If you want to change colour of the cell based on the value you have selected or being updated from another cell, you can use the snippet below:
File: js/tables.YourTableName.js
//Status
{ "width": 50, "targets": 2 ,
render: function (data, type, full, meta) {
if (data == "Open") {
return "<div class='text-wrap width-50 green-background'>" + data + "</div>";
}else{
return "<div class='text-wrap width-50'>" + data + "</div>";
}
}
},
-- end--
File: style.css
/Control for Data Fields Color Change/
.green-background {
background-color: green;
color: white;
}
-- end --
** It would help if someone could provide the code to change the entire row color also!
This discussion has been closed.
Replies
One way you could change the entire row is to use the createdRow callback function, which is an option of the DataTables Initialisation: