Row color based on value
Row color based on value

Hi. I have this code, that is working fine. But when I uncomment rowCallback function I get no data in the table. Can anybody help? Thanks in advance.
$(document).ready(function(){
$('#add_button').click(function(){
$('#user_form')[0].reset();
$('.modal-title').html("<i class='fa fa-plus'></i> Add User");
$('#action').val("Add");
$('#btn_action').val("Add");
});
$('#user_data').DataTable({
"processing": true,
"serverSide": true,
"order": [],
"ajax":{
url:"user_fetch.php",
type:"POST"
},
/*"rowCallback": function( row, data, index ) {
if (data.compania == "EIG") {
$(row).css('color', 'red');
}
}*/
"pageLength": 25
});
});
This question has accepted answers - jump to:
This discussion has been closed.
Answers
When the page doesn't seem to load properly you are probably getting a Javascript error. Take a look at your browser's console for errors.
Kevin
The rowCallback looks perfectly normal. I use it in the same way and it works fine. Have you checked your console for errors?
Is it really "data.compania" that you are retrieving or rather "data.yourTable.compania"?
Thanks for your help. Now it's showing data but not applying color.
It was a missing comma (error in console)-> thanks kthorngren.
rf1234, when you say: "yourTable", do you mean mysql table?
Again, thanks in advance.
Now it's working with data[5]. Thank you both!!