Export all data with Button extension

Export all data with Button extension

chungkid1no1chungkid1no1 Posts: 2Questions: 2Answers: 0
edited June 2016 in Free community support

Hello, I am using the html5pdf button to export data for my table (datasource is from ajax). My problem is that I can only export the first page of the table. Is there any way for me to export the entire table?

My table is defined as follow:

this.grid = $(this.gridTable).dataTable(
            {
                buttons: this.exportButtons,
                "bAutoWidth": false,
                "bFilter": true,
                "bSort": typeof context.sort === 'undefined' ? false : context.sort,
                'bServerSide': context.serverSide,
                "aaData": context.dataSource,
                "sScrollY": this.scrollAreaHeight,
                'sAjaxSource': context.ajaxSource,
                "fnServerData": function (sSource, aoData, fnCallback, oSettings) {
                    if (!sSource)
                        return;

                    oSettings.jqXHR = $.ajax(
                    {
                        "dataType": 'json',
                        "type": "GET",
                        "url": sSource,
                        "data": aoData,
                        "cache": false,
                        "success": function (msg) {
                            var json = JSON.parse(msg.d);
                            fnCallback(json);
                        }
                    });
                },
                "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
                "columns": context.columns,
                "aaSorting": (context.columns.length > 0 && context.columns[0].title == "ID" ? [[0, 'desc']] : []),
                "bPaginate": typeof context.enablePagination === 'undefined' ? false : context.enablePagination,
                "bLengthChange": typeof context.showLengthChange === 'undefined' ? false : context.showLengthChange,
                "sPaginationType": "bootstrap",
                "iDisplayLength": this.displayedRowsCount
})

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • Tom (DataTables)Tom (DataTables) Posts: 139Questions: 0Answers: 26

    Thanks for your question.

    I believe it's because you are using server-side processing.

    Server-side processing only shows a portion of the data to the user and because the export buttons are client side it can only export the data it has access to.

    If you wanted to get around this would either have to disable server-side processing or have the server create the file for you.

    Thanks

    Tom

This discussion has been closed.