使用数据表比较两列

compare two columns using datatables

我的目标是使用数据表在一行中的两列包含相同字符串时突出显示一行 我不确定如何比较两列。我想做这样的事情。 这是我的代码的一部分

  "columnDefs":[
  {
      "targets":[3,4], 
      "render": function ( data, type, full, meta ) { 
       if value of 3 = 4 {
         //highlight the row
       }
      }
   } ],

提前致谢。

SOLUTION

使用 rowCallback 选项定义绘制行时调用的回调函数。

$('#example').dataTable({
  "rowCallback": function(row, data, index){
    if (data[3] === data[4]) {
       $(row).addClass('selected');
    }
  }
});

DEMO

有关代码和演示,请参阅 this jsFiddle