datatables + how to combine server side processing code with File export code -
this datatables example of adding buttons export data csv, pdf, excel.... fiddle here
https://datatables.net/extensions/buttons/examples/initialisation/export.html
$(document).ready(function() { $('#example').datatable( { dom: 'bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ] } ); } );
this datatables example of server-side processing
https://datatables.net/examples/server_side/simple.html
$(document).ready(function() { $('#example').datatable( { "processing": true, "serverside": true, "ajax": "scripts/server_processing.php" } ); } );
now how combine above code one, have data tables server side processing , attempt, not sure wrong, or if indeed close.
$(document).ready(function() { $('#example').datatable( { "processing": true, "serverside": true, "ajax": "scripts/server_processing.php", "dom": 'bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ] } ); } );
i have tried various permutations still getting error in console uncaught syntaxerror: unexpected string
can advise?
this real example working
$(document).ready(function() { var datatable = $('#employee-grid').datatable( { "processing": true, "serverside": true, "ajax":{ url :"employee-grid-data2.php", // json datasource type: "post", // method , default error: function(){ // error handling $(".employee-grid-error").html(""); $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">no data found in server -- startagain1-index2.php </th></tr></tbody>'); $("#employee-grid_processing").css("display","none"); } }, "dom:" 'bfrtip', "buttons": [ 'copy', 'csv', 'excel', 'pdf', 'print' ] } ); } );
you have sintax error, change code in line:
incorrect:
"dom:" 'bfrtip',
correct:
"dom" : 'bfrtip',
result: jsfiddle
Comments
Post a Comment