[Question] is there a way to change to color of a row?
Good evening! Sorry, me again. My question is simple i want to know if there's a way to change the color of a row by doing a condition.
for example i have my data as the image below:
Is there a way i could use the "bad_provider" element to do a condition and if it turns out to be true i could change the row color to red?
I have seen the documentation of datatables and it seems that i could do that from the createdRow method:
function createdRow(row, data, dataIndex) {
// Recompiling so we can bind Angular directive to the DT
$compile(angular.element(row).contents())($scope);
}
But i don't know how to do the condition and change the row color, is there a way to do it? or am i even approaching to this problem correctly? Thanks for your attention
Nevermind i founded the solution by myself:
function createdRow(row, data, dataIndex) {
// Recompiling so we can bind Angular directive to the DT
if(data.bad_provider === true){
$('td', row).addClass('danger');
}
$compile(angular.element(row).contents())($scope);
}
Inside createdRow function just add the condition you want to make and then the changes in it, pretty simple. If you want a specific colour it could be like this:
$('td', row).addClass('background-color', 'blue');