Read Value of Hidden Column in JQuery

前端 未结 8 568
青春惊慌失措
青春惊慌失措 2020-12-20 13:09

I need to hide a column on the table, but after that I cannot read selected row\'s hidden column value.

 dtTable = $(\'#lookupTable\').DataTable({
       \"c         


        
8条回答
  •  北海茫月
    2020-12-20 13:51

    Traditional jquery wont work on datatable , you have to use API defined methods to get the value. In my case this worked fine to get hidden column value on button click in each row -

    $(function () {
           var t = $('#mytableid').DataTable({
                "columnDefs": [{
                    "searchable": false,
                    "orderable": false,
                    "visible":false,
                    "targets": [0]
                }]
            });
    
            $('#mytableid').on('click', '.btnClass', function () {
                var currentRow = $(this).closest("tr");
                var columnvalue = t.row(currentRow).data()[0];
                console.log(columnvalue);
            });
    });
    

提交回复
热议问题