Reputation: 29
My goal is to highlight a row if two columns contain the same string within a row using datatables I am not sure how would I compare two columns. I want to do something like this. This is part of my code
"columnDefs":[
{
"targets":[3,4],
"render": function ( data, type, full, meta ) {
if value of 3 = 4 {
//highlight the row
}
}
} ],
Thanks in advance.
Upvotes: 0
Views: 2695
Reputation: 58880
SOLUTION
Use rowCallback
option to define a callback function that will be called when row would be drawn.
$('#example').dataTable({
"rowCallback": function(row, data, index){
if (data[3] === data[4]) {
$(row).addClass('selected');
}
}
});
DEMO
See this jsFiddle for code and demonstration.
Upvotes: 3