Returning cell data from selected rows
Returning cell data from selected rows

Trying to select only column '0' data from selected rows. This is what I've got so far but the output shows every row data and not just selected..
Any help would be massively appreciated.
$('.datatable').DataTable( {
"dom": 'Bfrtip',
"buttons": [
{
"extend": 'selected',
"text": 'Send Invites',
"action": function ( e, dt, node, config ) {
var table = $('.datatable').DataTable();
table.rows({selected:true}).map( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.column(0).data();
new_data = data.join(',');
console.log(new_data);
//window.location.replace(new_data);
});
}
},
'selectAll',
'selectNone'
],
"select": 'multi',
"paging": false,
"bInfo" : false,
"scrollX": false,
"searching": true,
"responsive": true,
"order": [[0, 'asc']]
});
Thanks in advance!
Ben
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This will grab all the data in column 0 not just the row in the loop.
My suggestion is to use
rows().every()
with{selected:true}
to loop the selected rows. The documented example shows how to get the data for the row. From there you can access column 0 and append to an array or whatever you want to do. For example:Kevin
Absolutely spot on Kevin, works perfectly - I appreciate your help very much!
Not all heroes wear capes (unless you do wear a cape, in which case, my statement is incorrect, and heroes also wear capes)
Happy New Year
Ben