I am trying to export only the selected rows from a dataTable. I could successfully export selected rows to a csv file by setting extend option to csv as shown in the below code.
buttons: [
'colvis',
'selectAll',
'selectNone',
{
extend: 'csv',
text: 'Export Selected',
exportOptions: {
columns: ':visible:not(.not-exported)',
modifier: {
selected: true
}
},
title: 'Data export'
}
],
But I want to have a drop down(csv, copy, print) from which I can choose to export the selcted rows to. I tried using collection as in the below code. But it exports all the visible rows. Someone pls help
buttons: [
'colvis',
'selectAll',
'selectNone',
{
extend: 'collection',
text: 'Export Selected',
buttons: ['copy','csv','print'],
exportOptions: {
columns: ':visible:not(.not-exported)',
modifier: {
selected: true
}
},
title: 'Data export'
}
],