buttons not showing when create datatable inside the bootstrap modal
buttons not showing when create datatable inside the bootstrap modal
drhardian
Posts: 3Questions: 1Answers: 0
Hi All,
I have create a datatable on bootstrap popup modal and working properly, but I can't add buttons like Excel button, here is my code,
var tblToptenPersons = {
dom: 'Bf',
processing: true,
serverSide: true,
retrieve: true,
scrollCollapse: true,
scrollY: "450px",
scrollX: true,
buttons: [
'excel',
],
lengthMenu: [
[25, 50, 100, -1],
[25, 50, 100, "All"]
],
ajax: {
url: url,
data: function(d) {
d.finding = $('.toptenperson-finding').text();
d.id = $('#mcuactivity').val();
d.filterByVendorId= $('#filter_vendor_value').val();
d.filterByPackage= $('#filter_package_value').val();
}
},
order: [],
columns: [
{
data: 'medicalrecord', name: 'medicalrecord',
searchable: true, orderable: true
},
{
data: 'name', name: 'name',
searchable: true, orderable: true
},
{
data: 'gender', name: 'gender',
searchable: true, orderable: true
},
{
data: 'bod', name: 'bod',
searchable: true, orderable: true
},
{
data: 'location', name: 'location',
searchable: true, orderable: true
},
{
data: 'packagemcu', name: 'packagemcu',
searchable: true, orderable: true
},
]
};
function openToptenPersons(finding) {
$('.toptenperson-finding').text(finding);
$('#topTenPersonModal').modal('toggle');
$('#tblToptenPersons').DataTable().destroy();
$('#tblToptenPersons').DataTable(tblToptenPersons);
}
Answers
You must have
t
in the DOM somewhere as well - that is the table element.However, I'm not sure that is the issue. Can you link to the page showing the issue so I can debug it please?
Allan
Hi Allan,
Actually I'm running it on my local environment so I can't share the link, but finally I download the package including the buttons extension and it's working now, here is my complete setup before,
I still did not know which part that I've missed, because when I'm running it without modal, it's working well, but when inside a modal it doesn't display the button even though on inspect window the div button is appear but doesn't have any text
Hi Allan,
Here is my update code,
now it's working inside modal and without modal
Super - good to hear you got it working. Thanks for the update!
Allan