Skip to content

Instantly share code, notes, and snippets.

@hgirish
Created June 9, 2022 03:07
Show Gist options
  • Save hgirish/47553f54617a0f281fcff398ccc93c89 to your computer and use it in GitHub Desktop.
Save hgirish/47553f54617a0f281fcff398ccc93c89 to your computer and use it in GitHub Desktop.
<link href="~/lib/datatables/buttons.bootstrap5.min.css" rel="stylesheet" />
<link href="~/lib/datatables/dataTables.bootstrap5.min.css" rel="stylesheet" />
<script src="~/lib/datatables/jquery.dataTables.min.js"></script>
<script src="~/lib/datatables/dataTables.bootstrap5.min.js"></script>
<script src="~/lib/jszip/jszip.min.js"></script>
<script src="~/lib/datatables/js/dataTables.buttons.min.js"></script>
<script src="~/lib/datatables/js/buttons.colVis.min.js"></script>
<script src="~/lib/datatables/js/buttons.html5.min.js"></script>
<script src="~/lib/datatables/js/buttons.print.min.js"></script>
<script src="~/lib/datatables/buttons.bootstrap5.min.js"></script>
<script>
$(document).ready(function() {
$('#dataTable').DataTable({
dom: '<B<frtip>B>',
iDisplayLength: -1,
paging: false,
footer: true,
buttons: {
dom: {
button: {
className: 'btn'
}
},
buttons: [
{
extend: 'excelHtml5',
text: 'Excel',
className: 'btn-primary m-2',
exportOptions: {
columns: ':not(.notexport)'
},
filename: function() { return getExportFileName(); }
},
{
extend: 'print',
className: 'btn-default p-2'
}
]
}
});
});
function getExportFileName() {
return 'data-export';
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment