如何修改当前td节点class

How to modify the current td node class

当数据值为真时,如何修改当前数据的td class?

目前我只显示一个空值,但更新 td class 会显示一个图标。

columnDefs: [ 
   { targets: [ 1], visible: false, searchable: false },
   { 
      targets: [ 3], 
      render: function ( data, type, full, meta ) {
         if(type === 'display') {
            if(data==true){
               // add  class 'details-secret' to current node td
               return "";
            }
         }

         return data;
      }
   },

使用 createdCell 选项,如下所示:

columnDefs: [
   { targets: 1, visible: false, searchable: false },
   {
      targets: 3,
      createdCell: function(cell, data, index){
         if(data == true){
            $(cell).addClass('details-secret');
         }
      }
  },
  // ... skipped ...

参见 this example with similar method createdRow