I am trying to apply datatables buttons to my existing table, but cannot seem to get this to work. The main issue is that following the examples on the official website (and even posts here on SE), most user seems to load the table content VIA datatables AJAX, unlike me where I am dealing with an existing, PHP + MySQLi generated table.
In short, how can I apply this code from the manual:
$(document).ready(function (){
var table = $('#example').DataTable({
dom: 'frtip',
ajax: 'https://api.myjson.com/bins/qgcu',
buttons: [
{
extend: 'collection',
text: 'Export',
buttons: [ 'pdfHtml5', 'csvHtml5', 'copyHtml5', 'excelHtml5' ]
}
]
});
$('#btn-pdf').on('click', function(){
table.button( '0-0' ).trigger();
});
$('#btn-csv').on('click', function(){
table.button( '0-1' ).trigger();
})
to my JavaScript and apply it to the existing #dmlog_table?
<script type="text/javascript" class="init">
$('#dmlog_table').DataTable({
"pagingType": "full_numbers",
"lengthChange": false,
"searching": true,
"ordering": true,
"order": [[ 0, "desc" ]],
"info": true
});
</script>