get row data
get row data
harald
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!
This discussion has been closed.
Answers
Here is an example using buttons within one of the cells. It uses delegated events as shown in this [example] (https://datatables.net/examples/advanced_init/events_live.html). Maybe it will help with your solution. If you still need help please provide a simple test case or update my example showing what you have so we can provide more specific help.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin