Home:ALL Converter>Export all data regardless of pagination in datatables

Export all data regardless of pagination in datatables

Ask Time:2021-09-22T05:25:45         Author:Kevin

Json Formatter

Here is what I'm trying to do. I'm trying to export all of the data in a datatable regardless of the amount displayed on the page.

Based on the link: https://datatables.net/forums/discussion/48044/export-all-regardless-of-pagination

I tried to do the following:

but guess what I'm only able to export the csv file with only a certain amount of records.

   var datatableFilters_{$this->id} = ".App_Json::encode($this->strictFilters).";
        var datatablePassthru_{$this->id} = ".App_Json::encode($this->passthruVariables).";
        $( document ).ready(function() {
            var datatable = $('#{$this->id}').DataTable(
                {
                    
                    ".(($this->allowExporting) ? "dom: 'Bfrtip', buttons: [ { extend:'copy',exportOptions: {modifier: {page: 'all', search: 'none' } }, }, { extend:'csv',exportOptions: {modifier: {page: 'all', search: 'none', serverSide: 'false' } }, }, { extend:'excel',exportOptions: {modifier: {page: 'all', search: 'none' } }, }, { extend:'pdf',exportOptions: {modifier: {page: 'all', search: 'none' } }, }, { extend:'print',exportOptions: {modifier: {page: 'all', search: 'none' } }, } ], " : '')."
                    ".(($this->showRecordsPerPageAtBottom) ? "sDom: 'Rfrtlip'," : '')."
                    serverSide: true,
                    responsive: true,
                    pageLength: {$this->recordsPerPage},
                    searching: ".(($this->allowSearch) ? 'true' : 'false').",
                    paging: ".(($this->allowPagination) ? 'true' : 'false').",
                    ordering: ".(($this->allowSorting) ? 'true' : 'false').",
                    info: ".(($this->showRecordCount) ? 'true' : 'false').",
                    language: {
                        search: '_INPUT_',
                        searchPlaceholder: 'Search...'
                    },
                    $order
                    ajax: {
                        url: 'ajax.php',
                        type: 'POST',
                        data: function(d) {
                            d.ajaxAction = 'loadAjaxClassAction',
                            d.className = 'Browser_DataTable',
                            d.classFunction = 'ajaxProcess',
                            d.aryFunctionAttributes = jsonEncode([
                                '".get_called_class()."',
                                jsonEncode(datatableFilters_{$this->id}),
                                jsonEncode(datatablePassthru_{$this->id})
                            ])
                        }
                    }
                }
            );

Is there a way to export all records?

Author:Kevin,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275728/export-all-data-regardless-of-pagination-in-datatables
yy