Why datatble does not show my excel button
Why datatble does not show my excel button
Hi everyone, the fisrt one, im not really good english speaker but i try to communicate with you so well.
I'm using datatable , it's really amazing, im using the button export to excel and it works awesome, you can pick wich row want to import and which you don't want, you can implement the class for the custom desing, all work exellent but i have a problem and i dont know why.
The problem is this, i use the button excel into differents tables, las 5 or 6, but in 2 or 3 the button does not show it, i dont know why, because, im using a template and whit every dependency (just i need to import to excel now), but when i try to implement the same code base to impot to excel does not work, i don't know why and i feel that i spend like 3 or maybe 4 hours finding to fix the problem. If somebody knows about the problem or has the answer.
Here i will put the code one whit problem and the other whit one that works, and my dependencies
dependencies (im only need to use for export to excel now)
buttons.html5.min.js
dataTables.buttons.min.js
jquery.dataTables.min.js
jszip.min.js
**code that works on my page **
$(document).ready(function() {
var table = $('#myTable').DataTable({
"lengthMenu": [20],
"pageLength": 20,
'dom': 'Bfrtip',
'buttons': [
{
extend: 'excelHtml5',
className:'btn btn-success',
exportOptions: {
columns: [ 0, 1, 2, 3]
}
}
],
"ajax": {
"url": "indexBatery",
"dataSrc": "",
"type": "GET"
},
"columns": [
{ "data": "count"},
{ "data": "nfc" },
{ "data": "status"},
{ "data": "created" },
{ "data" : null,
className: "center",
defaultContent: '
Eliminar
'
}
]
});
});
code that does not work on my other page
$(document).ready(function() {
var table = $('#myTable').DataTable( {
"lengthMenu": [20],
"pageLength": 20,
'dom': 'Bfrtip',
'buttons': [
{
extend: 'excelHtml5',
className:'btn btn-success',
exportOptions: {
columns: [ 0, 1, 2, 3]
}
}
],
"ajax": {
"url": "indexFamoco",
"type": "GET",
"dataSrc": ""
},
"columns": [
{ "data": "id" },
{ "data": "idFamoco" },
{ "data": "estatus" },
{ "data": "modelo" },
{ "data" : null,
className: "center",
defaultContent: '<button class="btn btn-warning">Editar</button>'
},
{ "data" : null,
className: "center",
defaultContent: '<a class="btn btn-danger">Borrar</a>'
}
]
});
});
im going to still find the solution, however im hope that im doing something wrong and not a bug in datatable, regards
Answers
If you post a link to the page showing the issue, I would be happy to take a look and help you debug it.
Allan
i found it, my error was that i imported the same datatable.js in my view and in my template, i cant explaint why my datable worked normally but the button didnt. However when i removed the second one, the button tarted worked. thank you for your time and appreciate it.