2

use Angular4 and angular-datatables.

Everything looks fine (pagination, column sorting, export buttons), but when I try to print/copy/export a table, it only outputs the headers, even though the rest of the data is there.

Any ideas what's should I check?

this.dtOptions = {
  pagingType: 'full_numbers',
  pageLength: 20,
  serverSide: true,
  processing: true,
  ajax: (dataTablesParameters: any, callback) => {
   this.service.getServerSidePaganated(dataTablesParameters).subscribe(resp => {
      that.cdrs = resp.data;
      callback({
        recordsTotal: resp.recordsTotal,
        recordsFiltered: resp.recordsFiltered,
        data: []
      });
    });
  },
  columns: [
    { data: 'source' },
    { data: 'destination' },
    { data: 'dateTime'},
    { data: 'callTime'},
    { data: 'timeOnHold'},
    { data: 'disposition'},
    { data: 'recordingFileName'}
  ],
  // Declare the use of the extension in the dom parameter
  dom: 'Bfrtip',
  // Configure the buttons
  buttons: [
     'print',
     'excel'
  ]
};

}

1
  • Same issue, any solution? Commented Oct 9, 2020 at 20:19

1 Answer 1

1

you should set the callback data

 ajax: (dataTablesParameters: any, callback) => {
   this.service.getServerSidePaganated(dataTablesParameters).subscribe(resp => {
   //   that.cdrs = resp.data;  // remove this line
      callback({
        recordsTotal: resp.recordsTotal,
        recordsFiltered: resp.recordsFiltered,
        data:  resp.data  // set data
      });
    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.