get row data

get row data

haraldharald Posts: 16Questions: 7Answers: 1

Hello everyone,

I try to get row data, but it doesn´t work so far...

I have a table with the id 'tableId'. In the last column is an icon, which on click starts a function to export the row data. So far I tried following:

   function getRowData(){
       var table = $('#tableId').DataTable();
       var data_row = table.row($(this).closest('tr')).data();
       console.log(data_row);  // data_row is undefined
   }

I aslo tried:

       var table = $('#tableId').DataTable();

       $('#tableId tbody').on( 'click', 'tr', function () {
           console.log( table.row( this ).data() );
       } );

Would be happy for some help. Thank you!

Answers

Sign In or Register to comment.