Angular 9 - DataTables - Print/Excel/CSV/Copy is not working for server side pagination
Angular 9 - DataTables - Print/Excel/CSV/Copy is not working for server side pagination

Angular 9 - DataTables - Print/Excel/CSV/Copy is not working for server side pagination
this.dtOptions = {
pagingType: 'full_numbers',
pageLength: AppConstants.PAGE_LIMIT,
serverSide: true,
processing: true,
responsive: true,
ordering: false,
ajax: (dataTablesParameters: any, callback) => {
const filter = {};
filter['start'] = dataTablesParameters.start;
filter['limit'] = dataTablesParameters.length;
filter['appointee_name'] = dataTablesParameters.search.value;
filter['appointment_status'] = this.appointment_status;
this.pageNumber = dataTablesParameters.start/dataTablesParameters.length;
this.appointmentsService.getAppointments(filter).subscribe(resp => {
this.appointments = resp.data.appointments;
callback({
recordsTotal: resp.data.recordsTotal,
recordsFiltered: resp.data.recordsTotal,
data: []
});
})
},
columns: [{ data: '_id', width: '5%' }, { data: 'clinic', width: '15%' },{ data: 'name', width: '15%' }, { data: 'gender', width: '3%' },{ data: 'contact', width: '20%' }, { data: 'service', width: '20%' }, { data: 'date', width: '25%' } ,{ data: null, width: '4%' }, { data: null, width: '4%' }],
dom: 'Bfrtip',
buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ]
};
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
If by 'not working' you mean you're only getting the data shown on the current page, then that's to be expected as you're using
serverSide
. See this thread here for a solution.If anything else, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin