Add buttons not work
Add buttons not work
Wilmer30
Posts: 33Questions: 10Answers: 1
Hi,
I am trying to add buttons to a series of tables, but it does not work:
var table = $('table.table').DataTable({
order: [[ 0, "desc" ]],
"paging": false,
"info": false,
responsive: true,
columnDefs:[
{className: "text-right","targets":[3,4]},
{className: "text-center","targets":[2,5]}
],
"language":
{
"url": "<?php echo base_url('vendors/datatables.net/i18n/Spanish.json') ?>",
}
});
<?php foreach ($lista as $key => $value): ?>
console.log(table.table(parseInt('<?php echo $key ?>')).data());
table.table(parseInt(parseInt('<?php echo $key ?>'))).button().add(0, {
text: 'Boton'
});
<?php endforeach ?>
According to the referral, this should work.
On line 17 you can see that you get the data correctly.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Did you load the buttons extension JS and CSS includes:
https://datatables.net/extensions/buttons/
You might need to use the
dom
option to place the buttons:https://datatables.net/extensions/buttons/#dom-parameter
Kevin
Ok, the problem here:
In languaje, I do not know why but when I use languaje it does not display the button, any idea?
I don't actually see where you are adding the buttons, but if you use
language.url
you should useinitComplete
to add the buttons, sincelanguage.url
makes the loading async.Allan
The buttons add in
In this way it works
You'd need to add them in
initComplete
as I mentioned above. Thelanguage.url
option makes the loading of the table async.Allan
Thank you clarification