DataTable get hidden column value on click

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

    Here is an example of getting row's data on a click.

    Suppose you have Delete or any button with each row of the table and if you click on the button, get the data of the selected row and perform required operation.

    $(document).ready(function(){
        $('#example tbody').on('click', '.delete', function(){
            var row = $(this).closest('tr');
            var data = $('#example').dataTable().fnGetData(row);
            console.log(data);
        }); 
    });
    

提交回复
热议问题