Buttons Disappear after adding ajax:"..." data source
Buttons Disappear after adding ajax:"..." data source
Buttons Show when i use html data.
$(document).ready(function() {
var table = $('#example').DataTable( {
lengthChange: false,
buttons: true
} );
table.buttons().container()
.insertBefore( '#example_filter' );
});
</script>
but when i want to use ajax data source, the buttons disappear.
$(document).ready(function() {
var table = $('#example').DataTable( {
lengthChange: false,
buttons: true,
ajax: "setData.php",
columns: [...............]
} );
table.buttons().container()
.insertBefore( '#example_filter' );
});
This question has accepted answers - jump to:
This discussion has been closed.
Answers
You need to use
initComplete
to insert your buttons if you are using an asynchronous initialisation.Allan
Thank You Allan. It works Perfect. Is it Possible to appendto(); the default position of the table? What is the id for the default button position. I have tried (id="example_length") as appendto("#example_length"); but doesnt show, it does work in any other id element outside the table. Is it possible to display the buttons in default position?
OK Found it, Thanks.
I have the same problem. I didn't know how to use initComplete to insert my buttons.
Di you have example to insert button.
var table = $('#example').DataTable( {
stripeClasses: [ 'strip1', 'strip2'],
ajax: "setData.php",
lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
initComplete: function( settings, json ) {
table.buttons().container().appendTo('#UserHead');
},
select: true,
"bJQueryUI": true,
order:[0,'des'],
columns: [
Thanks a lot but I didnt arrive to make it run....
I create a new question to have help.