DataTable export columns
DataTable export columns
Steveb13
Posts: 11Questions: 5Answers: 0
Hi, I am wishing to export to PDF a table. I have used Colvis to select the columns but when exporting All columns are exported. Is their a f=unction for me to just Export the selected columns, Thanks
This question has accepted answers - jump to:
Answers
Use
There is also an example in the docs:
https://datatables.net/extensions/buttons/examples/print/columns
Thanks for replying. This worked for one option but I was wishing to have 3 options "Print. PDF and Excel. If i try to add them as extra options I have No Option display. Should I be pursuing this or is this a limitation. Thanks
$(document).ready(function () {
$('#myTable').DataTable(
{
dom: 'Bfrtip',
buttons: [
{
extend: 'pdf',
exportOptions: {
columns: ':visible'
}
},
'colvis'
],
"scrollY": "550px",
"scrollCollapse": true,
"paging": true,
"order": [[0, "asc"]],
lengthMenu: [[10,25,-1],[10,25,"All"]],
"columnDefs": [{
"targets": [3,4,5,6],
"searchable": false,
"orderable": false
}]
}
);
});
Hi, I have solved it. All I needed to do was add the "extend" separately for each option I wanted. Thanks for giving me the right direction, cheers
Super - thanks for the update. Good to hear you've got it working as you need now.
Allan