In this article, we will see how to remove/hide columns while export data in datatables in laravel 8. When we are using jquery datatable for displaying data in datatable and exporting datatable information into PDF, Excel, or CSV we might exclude or hide some columns. So, we will give you a demo of how to remove/hide columns while exporting data in datatables in laravel 8 using jQuery.
So, let's see, datatables export only visible columns, exclude columns from export in jquery datatables and remove columns when exporting data when using jquery.
In this example the copy button will export column index 1 and all visible columns, the Excel button will export only the visible columns and the PDF button will export column indexes 1, 2, and 4 only and other datatable hide columns.
Column visibility controls are also included so you can change the columns easily and see the effect of the export options.
$(document).ready(function() {
$('#demo').DataTable( {
dom: 'Bfrtip',
buttons: [
{
extend: 'copyHtml5',
exportOptions: {
columns: [ 1, ':visible' ]
}
},
{
extend: 'excelHtml5',
exportOptions: {
columns: ':visible'
}
},
{
extend: 'pdfHtml5',
exportOptions: {
columns: [ 1, 2, 4 ]
}
},
'colvis'
]
} );
} );
You might also like:
In this article, I will give you an example of the TinyMCE editor, Tinymce editor is a rich-text open-source editor,&nbs...
Jun-18-2020
In this small post i will show you how to disable right click using jquery. Here, we will disable right click on pa...
Aug-18-2021
In this article, we will see carbon add hours to date in laravel 9. Carbon provides addHour and addHours() function...
Nov-22-2022
In this article, we will see how to encrypt and decrypt a string in laravel 9. Using crypt helper, As we all know larave...
Mar-09-2022