Doubt about deferRender in ajax calls

Doubt about deferRender in ajax calls

Tiago Azevedo BorgesTiago Azevedo Borges Posts: 11Questions: 2Answers: 0
edited March 2018 in Free community support

I have a question, if the deferRender option is false, should the DataTables create all the HTML elements, even if the serverSide option is true?
Should not the pageSize be ignored when deferRender is false?

My intention is to be able to use the print button and pick up all the items of the call and not just those that are being shown in the table.

My code:

$(function () {
            var table = $('#dataTable').DataTable({
                serverSide: true,
                deferRender: false,
                ajax: {
                    'url': '@Url.Action("List", "Consignataria")',
                    'error': function(xhr, textStatus, error) {
                        alert(error);
                    }
                },
                lengthMenu: [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
                buttons: ["print"],
                columns: [
                    { 'data': 'Id', 'name': 'Id', 'autoWidth': true },
                    { 'data': 'Name', 'name': 'Name', 'autoWidth': true },
                    { 'data': 'Number', 'name': 'Number', 'autoWidth': true }
                ],
                initComplete: function () {
                    var api = this.api();
                    api.buttons().container().appendTo($("#table-actions"));
                }
            });
        });

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945

    See the "How can I export the whole table when using serverSide and Buttons." FAQ in this section:
    https://datatables.net/faqs/index#Server-side-processing

    How rows do you have total in your table? Maybe you don't need server side processing enabled. The export buttons only pickup the data in the client.

    Kevin

  • Tiago Azevedo BorgesTiago Azevedo Borges Posts: 11Questions: 2Answers: 0

    I would like to take advantage of the filter, ordernation, etc. of DataTables on exporting but taking the content of all the pages.
    We could have a way to create a temporary data source to use for export.

    But anyway thank you.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    if the deferRender option is false, should the DataTables create all the HTML elements, even if the serverSide option is true?

    No. deferRender is basically irrelevant when serverSide is enabled, since server-side processing will only request the data for the current page.

    Should not the pageSize be ignored when deferRender is false?

    No. Use paging if you want to disable paging. Also consider that if you have server-side processing enabled, it is pointless to disable paging since you'd be loading the entire data set on every draw. You wouldn't be getting any performance benefit and would only be introducing network latency.

    Allan

This discussion has been closed.