lundi 17 octobre 2016

How do I export data from jquery datatable in laravel 5.3?

I would want to export data from jquery datatables to PDF and CSV formats. I am following this http://ift.tt/1MI5x4s however I am unable to insert

$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    } );
} ); 

properly to my working code.

<script>
$(function() {
$('#payments-table').DataTable({
processing: true,
serverSide: true,
scrollX: true,

ajax: '{!! route('HomeControllerPaymentsData') !!}',
columns: [
{ data: 'id', name: 'id' },
{ data: 'name', name: 'name' },
{ data: 'amount', name: 'amount' },
{ data: 'trans_id', name: 'trans_id' },
{ data: 'msisdn', name: 'msisdn' },
{ data: 'time_paid', name: 'time_paid' },
{ data: 'account', name: 'account' },
{ data: 'orgaccountbalance', name: 'orgaccountbalance' }
]

});
});
</script>

Kindly would someone help me to combine the two scripts to have the buttons appear? Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire