获取行数据的函数只能在数据表的响应模式下工作
当我以响应模式单击图像时,它将在控制台中返回行数据。但在正常情况下,我得到未定义的错误。获取行数据的函数只能在数据表的响应模式下工作
  var table = $('.dataTable').DataTable({        "responsive": true,         
       "columnDefs": [{ 
        "targets": 4, 
        "data": null, 
        "render": function (data, type, full, meta) { 
         if (type === 'display') { 
          data = "<a href='#' width='30px' class='editMe' data='" + full[0] + "'><img src='/images/edit.png' width='30px' /></a>"; 
         } 
         return data; 
        } 
       } , 
       { 
         "targets": 0, 
         "visible": false, 
         "searchable": false 
       }] 
      }); 
      $('.dataTable').on('click', '.editMe', function() { 
       console.log(table.row(this).data()); 
      }); 
回答:
使用下面的代码来代替:
$('.dataTable').on('click', '.editMe', function() {     var $row = $(this).closest('tr'); 
    if($row.hasClass('child')){ $row = $row.prev(); } 
    console.log(table.row($row).data()); 
}); 
代码和演示见this example。
以上是 获取行数据的函数只能在数据表的响应模式下工作 的全部内容, 来源链接: utcz.com/qa/262443.html

