How to print all records when serverSide is true

How to print all records when serverSide is true

rdmrdm Posts: 192Questions: 54Answers: 4

I understand that when setting serverSide: true, you can only print what you see in the table.

Is there a way to configure the print button so that you can print all records, and not only the ones seen that moment in the table?

As a workaround, I suppose I could disable scroller (going back to paging) and add a "select all" option. But I'm hoping I could keep Scroller enabled and be able to print all records. Is this possible?

[...code...],
serverSide: true,
scrollX: true,
scrollY: 300,
deferRender: true,
scrollCollapse: true,
scroller:true,
buttons: [
{ extend: "edit", text:'Edit selected row' ,editor: editor },
{ extend: "colvis", text:'Select Visible Columns' },
{
    extend: 'print',
    autoPrint: true,
    exportOptions: {
        columns: ':visible'
    }
}
],
[...code...]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin
    Answer ✓

    What you would have to do is use a custom button that will set the page length to be -1 (page.len()), wait for that draw to complete (draw - since it is an async action) and then trigger the print action (see buttons.buttons.action for how to call a method of the original buttons).

    Then (because that's not enough ;)) reset the page length back to whatever it was before.

    The whole point of server-side processing is that it only loads the records needed at the client-side for a specific draw. As soon as you need all records, all you are doing with server-side processing is introducing network latency into the application. If you really need all records, just drop server-side processing.

    Allan

  • rdmrdm Posts: 192Questions: 54Answers: 4

    It makes sense. The simpler option sounds like to drop Scroller and have an "all" option.

This discussion has been closed.