使用数据表比较两个列

compare two columns using datatables

本文关键字:两个 数据表 比较      更新时间:2023-09-26

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

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

<

解决方案/strong>

使用rowCallback选项定义一个回调函数,将在绘制行时调用。

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