DataTable get hidden column value on click

后端 未结 4 2190
野趣味
野趣味 2021-01-16 03:02

I have a datatable that is created with Ajax. However, I do not want all the fields to be displayed and thus I set bVisible to false on the not-so-important field.



        
4条回答
  •  囚心锁ツ
    2021-01-16 03:25

    On the Datatables v1.10.x I've used this method:

    Column definition:

    "columnDefs": [
        { "data": "yourColumnId", "targets": 0, "visible": false
    ]
    

    And then in my function...

    var rows = $("#tbl").dataTable().fnGetNodes();
    
    for (var i = 0; i < rows.length; i++) {
    
      id = $("#tbl").dataTable().fnGetData(i).yourColumnId;
    
    }
    

    I prefer this method instead of the:

    id = $(rows[i]).find("td:eq(0)").html();
    

提交回复
热议问题