Hi Guys,
I'm tried to make export 2 button to pdf and excel extension, nothing error shown but just silent button when clicked.
I was follow step by step the documentation https://datatables.net/extensions/buttons/examples/html5/simple.html but still not working.
Any help could be appriciate.
View
@using System.Data
@model DataTable
@{
ViewBag.Title = "Report By Date Parameter";
Layout = "~/Views/Shared/AdminDashboard/_Layout.cshtml";
}
<script src="~/assets/plugins/DataTableExport/jquery-3.5.1.js"></script>
<script src="~/assets/plugins/DataTableExport/jquery.dataTables.min.js"></script>
<script src="~/assets/plugins/DataTableExport/dataTables.buttons.min.js"></script>
<script src="~/assets/plugins/DataTableExport/jszip.min.js"></script>
<script src="~/assets/plugins/DataTableExport/pdfmake.min.js"></script>
<script src="~/assets/plugins/DataTableExport/vfs_fonts.js"></script>
<script src="~/assets/plugins/DataTableExport/buttons.html5.min.js"></script>
<link href="~/assets/plugins/DataTableExport/jquery.dataTables.min.css" rel="stylesheet" />
<link href="~/assets/plugins/DataTableExport/buttons.dataTables.min.css" rel="stylesheet" />
<script type="text/javascript" lang="javascript">
$(document).ready(function () {
$('#example').DataTable({
dom: 'Bfrtip',
buttons: [
'excelHtml5',
'pdfHtml5'
]
});
});
</script>
<div align="right">
<button class="btn btn-primary" tabindex="0" aria-controls="example" type="button"><span>Export To Excel</span></button>
<button class="btn btn-primary" tabindex="0" aria-controls="example" type="button"><span>Export To PDF</span></button>
</div>
<table id="example" class="display" style="width:100%">
<thead class="text-center align-middle vertical align-content-center" style="background-color:aquamarine">
<tr>
<th>Kode Pinjam</th>
<th>Tanggal Pinjam</th>
<th>Tanggal Kembali</th>
<th>Kode Petugas</th>
<th>Nama Petugas</th>
<th>Kode Anggota</th>
<th>Nama Anggota</th>
</tr>
</thead>
<tbody class="text-center">
@foreach (DataRow row in Model.Rows)
{
<tr>
<td style="width:10%">
@row["Kode_Pinjam"]
</td>
<td style="width:10%">
@row["Tanggal_Pinjam"]
</td>
<td style="width:10%">
@row["Tanggal_Kembali"]
</td>
<td style="width:10%">
@row["Kode_Petugas"]
</td>
<td style="width:10%">
@row["Nama_Petugas"]
</td>
<td style="width:10%">
@row["Kode_Anggota"]
</td>
<td style="width:10%">
@row["Nama_Anggota"]
</td>
</tr>
}
</tbody>
</table>