Cell class change based on value
Cell class change based on value

Hello.
I'm trying to change <td> cell class based on its value.
Database columns
Column that I want to edit.
My code, but nothing changes
var table = $('#user_details').DataTable( {
"rowCallback": function( row, data ) {
if ( data[4] == "Active" ) {
$('td:eq(4)', row).addClass('positive');
}
},
ajax: 'php/table.user_details.php',
...
My goal is to do as shown here
What am I doing wrong? Thanks in advance!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Likely it boils down to this if statement:
What value does
data[4]
have? You can use console.log or the browser's debugger to take a look.data[4]
. needs to match your data structure, array or object, and it needs to reference an existing element in the data.If this doesn't help then we will need a link to your page or a running test case showing the issue so we can take a look. Or you will need to debug the
rowCallback
function to determine the problem.Kevin
Thanks, Kevin! That helped
This code works for me