Skip to content

Instantly share code, notes, and snippets.

@r1d3rzz
Created September 18, 2024 06:34
Show Gist options
  • Save r1d3rzz/1f062f75d37c689ee8bc3923461b4812 to your computer and use it in GitHub Desktop.
Save r1d3rzz/1f062f75d37c689ee8bc3923461b4812 to your computer and use it in GitHub Desktop.
config for datatable file export
$.extend(true, $.fn.dataTable.defaults, {
processing: true,
responsive: true,
mark: true,
order: [[0, "desc"]],
iDisplayLength: 5,
aLengthMenu: [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
layout: {
topStart: {
buttons: [
'copy',
'csv',
{
extend: 'excelHtml5',
text: 'Export to Excel',
title: null, // Remove the custom title/header
exportOptions: {
columns: [0, 1, 2, 3, 4, 5] // Adjust the columns as needed
}
},
'pdf',
'print'
]
}
},
columnDefs: [
{ visible: false, targets: 'hidden' },
{ orderable: false, targets: 'no-sort' },
{ width: '10%', targets: 'rdlMenuName' },
],
language: {
paginate: {
previous: "<i class='fa-solid fa-angle-left'></i>",
next: "<i class='fa-solid fa-angle-right'></i>"
}
}
});
$(document).ready(function () {
$("#defaultDataTable").DataTable({});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment