Buttons don't appear and I got string error
Buttons don't appear and I got string error
Whenever I add the buttons all the datatables don't work and I have a string error...
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/jq-3.2.1/dt-1.10.16/b-1.5.1/b-html5-1.5.1/datatables.min.css"/>
<
script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"</script>
<
script src="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"</script>
$(document).ready( function () {
var table = $('#ServerTable').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy', 'excel', 'pdf'
]
"paging": false,
"columnDefs": [
{ targets: [0, 9], "orderable": false},
{
type: 'natural',
"searchable": true,
"orderable": true,
"targets": 1
} ],
"order": [[ 1, 'asc' ]]
} );
Answers
I see a couple issues. First is your CSS and JS.
This:
script src="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"</script>
Duplicates the CSS loaded in this line:
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/jq-3.2.1/dt-1.10.16/b-1.5.1/b-html5-1.5.1/datatables.min.css"/>
The buttons CSS is loaded with this portion
b-1.5.1/b-html5-1.5.1
. But it doesn't look like you are loading the buttons JS files as you only have this:script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"</script>
I would recommend using the Download Builder to build the proper CSS and JS. You also need to include
JSZip
for Excel andpdfmake
for PDF. Replace what you have above with the newly generated CSS and JS.Second you have a syntax error (which is probably the string error) in your Datatables init code. You need to change this:
To include a comma to separate the parameters, to look like this:
Kevin
Now the buttons appear!
But when I click on one of them they seem to be loading... but not functioning .. it seem like it take them long time to continue
I would suspect a Javascript error. Have you looked at your browser's console for messages?
Kevin
Question posted in new thread here:
https://datatables.net/forums/discussion/46744/buttons-stuck-on-loading-when-i-click-on-them-any-reason-why#latest
Kevin