I'm utilizing Datatables.Net within my Angular project and everything is functioning properly. I have successfully added a Print Button and can preview the table contents. However, I am looking to customize it further by adding additional details just above the table, allowing me to display specific data in the Preview mode. My goal is to be able to print or save the content as a .pdf.
I am seeking a solution that will enable me to insert dynamic HTML code that will be rendered in the Print Preview.
Here is the initialization method of my Datatable:
$('#myTable').DataTable({
data: this.data,
retrieve: true,
orderClasses: false,
responsive: true,
scrollX: true,
paging: true,
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'Excel',
},
{
extend: 'print',
title: 'Print Table',
}
],
"columns": [
{ "data": "Col1", className: "text-center", width: "17%" },
{ "data": "Col2", className: "text-center", width: "17%" },
{ "data": "Col3", className: "text-center", width: "20%" },
{ "data": "Col4", className: "text-center", width: "20%" },
{ "data": "Col5", className: "text-center", width: "17%" }
]
});
CSS references in index.html:
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css">
Script reference in my angular-cli:
"assets/datatable/js/jquery.dataTables.min.js",
"assets/datatable/js/dataTables.buttons.min.js",
"assets/datatable/js/buttons.flash.min.js",
"assets/datatable/js/jszip.min.js",
"assets/datatable/js/pdfmake.min.js",
"assets/datatable/js/vfs_fonts.js",
"assets/datatable/js/buttons.html5.min.js",
"assets/datatable/js/buttons.print.min.js",