I have the following initialization for my datatables:
$(document).ready(function() {
$('.datatable').dataTable({
dom: 'Bfrtip',
buttons: [
{
extend: 'copyHtml5',
text: 'Copy Content to Clipboard',
className: 'btn',
},
{
extend: 'excelHtml5',
text: 'XLS Download',
className: 'btn',
"mColumns": [ 8 ]
},
{
extend: 'csvHtml5',
text: 'CSV Download',
className: 'btn',
"mRender": function (data, type, row) {
console.log(data);
}
},
],
});
});
I am using Datatable Buttons as tabletools is deprecated from data table and tried many options:
"mRender": function (data, type, row) {
console.log(data);
}
Also tried:
"mColumns": [ 8 ]
I have tried applying the different parameters in various ways but there is something missing in my understanding.Kindly help.
Thanks.
Look for
exportOptions.columns
,exportOptions
let you define a column-selector the same way as you would target specific columns for filtering and so on. Example, include only the third and fourth column in a PDF export :demo -> https://jsfiddle.net/r9Lqbhz4/
Other examples :
And so on, see the above mentioned column-selector page,
As per comment: All visible columns except for one in particular :
Will include all visible columns except column #2, the third column. Be aware that the
eq()
column index is based on visible column indexes.