DataTable get hidden column value on click

后端 未结 4 2192
野趣味
野趣味 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:05

    get current tr data using following code(also returns hidden columns value perfectly):

    $('#example-table-id').dataTable().fnGetData($('currenttr'));
    

    it returns an array and you can access to td values like follow:

    $('#example-table-id').on('click', 'tbody tr', function(){
        var arr=$('#example-table-id').dataTable().fnGetData($(this)); 
        var Id=arr[0]; //returns first td value 
        var Name=arr[1];//returns second td value
    }
    

提交回复
热议问题