Here I'm trying to add default excel export functionality for my JS project,
in profiles.js
I have following code,
initDataTable({
tableId: "#profilesStatusTable",
orderVal: 1,
sortingDirection: "asc",
targetsVal: [0, 7],
dom : 'Bfrtip',
buttons : [ {
extend: 'excel',
text: 'Export To Excel'
} ]
});
//Existing code for filter purpose
$("#organizationFilterDropdown").dropdown();
$("#organizationFilterDropdown").dropdown({
onChange: function(value, text, $choice) {
if (value === "Organisation") {
// Reset option selected
resetTableRecords(); // Call the function to reset the table records
} else {
var selectedOrganizationId = value;
console.log(selectedOrganizationId);
var profilesStatusTable = $("#profilesStatusTable").DataTable();
profilesStatusTable.column(5).search(selectedOrganizationId).draw();
}
}
});
But I cannot see any buttons , I also tried applying following in order where the table is implemented _status_table.html.erb
,
<table>
//code for table
</table>
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/buttons/1.4.0/css/buttons.dataTables.min.css" />
<script type="text/javascript"
src="https://cdn.datatables.net/buttons/1.3.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript"
src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.html5.min.js"></script>
Aucun commentaire:
Enregistrer un commentaire