Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82353

Enabling DeferRender in Datatable improved performance but fails in exporting data.

$
0
0

Hi,

I am using data table to load huge amount of data and making "deferRender to true has helped to improve the performance but I have custom code to export the data to excel including input text column.

When I try to export to excel it fails ONLY WHEN DeferRender IS TRUE.

Kindly help

Here is the code-

table = $('#table').DataTable({
                "ajax": {
                    "url": "../API/GETALLITEMS",
                    "type": "GET"
                },
                "deferRender": true,
                dom: 'T<"clear"><"pull-right"B>lfrtip',
                lengthChange: true,
                buttons: [
                    {
                        extend: 'excelHtml5', text: 'Export to Excel', className: "btn-primary", exportOptions: {
                            format: {
                                body: function (data, row, column, node) {
                                    if (column === 11) {// Column 11 is a INPUT TEXT
                                        debugger;
                                        var id = '#' + node.firstChild.id; // **It is a input text and fails here only when the deferRender is true but working fine when deferRender is false.**
                                        if ($(id).val()) {
                                            return $(id).val();
                                        }
                                        else {
                                            return "";
                                        }
                                    }
                                    else {
                                        return data;
                                    }
                                }
                            }
                        },
                        action: function (e, dt, node, config) {
                            $.fn.dataTable.ext.buttons.excelHtml5.action.call(this, e, dt, node, config);
                        }
                    },
                ],

Thanks!
Puneet

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


Viewing all articles
Browse latest Browse all 82353

Trending Articles