Data Table buttons not showing
Data Table buttons not showing
x2noe
Posts: 6Questions: 2Answers: 0
the data tables buttons not showing unless i select an option from a drop down then the buttons appear. Is there a way to have the buttons showing without having to select an option from a drop down.
$(document).ready(function() {
var formD = document.getElementById('from_date').value;
var toD = document.getElementById('to_date').value;
var comp = document.getElementById('company').value;
// var com = document.getElementById('company').options[comp].text;
// var curN = document.getElementById('currency').value;
// var curR = document.getElementById('currency').options[curN].text;
$('#content').DataTable( {
dom: 'Bfrtip',
lengthMenu: [
[ 10, 25, 50, -1 ],
[ '10 rows', '25 rows', '50 rows', 'Show all' ]
],
buttons: [
'pageLength',
'copyHtml5',
{
extend: 'excelHtml5',
title: 'X2 Pay Account Statement',
messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r From Date: '+formD+' To Date: '+toD
},
{
extend: 'csvHtml5',
title: 'X2 Pay Account Statement',
messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r From Date: '+formD+' To Date: '+toD
},
{
// extend: 'pdfHtml5',
// orientation: 'landscape',
// download: 'open',
// pageSize: 'LEGAL',
// title: 'X2 Pay Account Statement',
// messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r From Date: '+formD+' To Date: '+toD+' \n\r Currency : '+ curR
extend: 'pdfHtml5',
orientation: 'landscape',
download: 'open',
pageSize: 'LEGAL',
title: 'X2 Pay Account Statement',
footer: true,
customize: function(doc){
doc['footer']=(function(page, pages) {
return {
columns: [
'',
{
alignment: 'center',
text: [
{ text: page.toString(), italics: true },
' of ',
{ text: pages.toString(), italics: true }
]
}
],
margin: [10, 10]
}
});
},
messageTop: 'Company : <?= @$this->userdata->company_name ?>\n\r From Date: '+formD+' To Date: '+toD+' \n\r Company ID:'+ comp
}
]
} );
} );
This discussion has been closed.
Answers
What drop down? Can you link to a test page showing the issue please.
Allan
jsfiddle.net/noe_n/ucute16u
so im using the data table buttons to save as pdf, csv, excel. I am using some javascript to pull out the information when the user selects a company, currency, date to display on the pdf but when you land on the page initially nothing will be selected so the buttons do not show until the user selects something but when the user lands on this specific page, all companies are shown so at the moment can not extract that information for all companies.
Thanks for the jsfiddle, but its not actually running, giving Javascript errors. Can you link to a running test case showing the issue?
Thanks,
Allan