KSI Posted January 25, 2022 Share Posted January 25, 2022 Currently I'm using Datatables with pagination. Now I recently added the Datatable.buttons library to use Export to Excel option. Now this functionality works fine but it only exports the first 10 rows of the page I'm currently in due to pagination. Now if I remove the limit in my model class, it will export all the entries which is what I want but it also gets rid of the pagination which decreases my site performance. The following is my current AJAX call code for getting Datatable data: $('#datatable.table').DataTable({ searching: true, paging: true, processing: true, serverSide: true, bFilter: true, dom: 'Bfrtip', async: false, 'columnDefs': [ { 'targets':[0,1,31,32,33,34,35,36,37], 'orderable': false, }], buttons: [ { text:"Export to Excel", extend: 'excelHtml5', exportOptions: { columns: ':visible', modifier:{ page:'all' } } }, ], ajax: { "url": '<?php echo site_url('listings/dtlists'); ?>', "type": "POST" }, columns: [{ data: "title", className: "column5" }, ... Now I've added page:'all' in my modifier, but it still only prints the 1st pagination page. So is there any way that I can use a different model function just for the export button where I can customize the limit manually? Quote Link to comment https://forums.phpfreaks.com/topic/314455-exporting-datatable-data-in-excel-with-a-different-model-function/ Share on other sites More sharing options...
maxxd Posted January 25, 2022 Share Posted January 25, 2022 Give the documentation, it looks like the functionality you want is the default. I've not used DataTables but I'd start by removing the `columns: ':visible'` from your exportOptions object; the pages aren't visible so that may have something to do with it. Quote Link to comment https://forums.phpfreaks.com/topic/314455-exporting-datatable-data-in-excel-with-a-different-model-function/#findComment-1593592 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.