Search code examples
csvjquery-pluginsdatatabledatatablesexport-to-csv

export yajra datatable all data to csv


I'm not able to find any solution for saving all the records to CSV using yajra datatables.

Currently i'm getting paginated records that are displaying on current screen (10 records), what i need is all the records

I'm using yajra datatables buttons extension.

My current code is :

    $('#export-table').DataTable({
    dom: 'Bfrtip',
    processing: true,
    serverSide: true,
    responsive: true,
    autoWidth:false,
    aaSorting: [[6, 'desc']],
    ajax: '{!! route('export.data') !!}',
    aoColumns: [
        {mData:'name', name: 'name'},
        {mData:'address', name: 'address'},
        {mData:'phone', name: 'phone'},
        {mData:'cell_phone', name: 'cell_phone'},
        {mData:'email', name: 'm.email'},
        {mData:'company', name: 'company'},
        {mData:'date_taken', name: 'date_taken'}
    ],
    buttons: ['csv']
});

Need help to save all records to csv

UPDATE

I'm using yajra datatables plugin with laravel 5.0


Solution

  • After a day long try, i was able to resolve my question and the answer is to change serverSide option value from true to false.

    serverSide: false
    

    It may help someone