Data Tables Buttons : Exporting to Excel

Data Tables Buttons : Exporting to Excel

tomzntomzn Posts: 29Questions: 9Answers: 2

Hi All,

I am using the datatables buttons extension with bootstrap styling to export the contents of my table to pdf. My data is server side and I am also using expandable/collapsible rows in the table which contain another table who's contents are rendered dynamically via an ajax call. I am experiencing the following issues and any help would be appreciated :

1) This is the most important one : At the moment when I export to pdf only the contents of the "main" parent table are displayed in the document. I.E The contents of any expanded rows are not shown in the exported PDF. Is there anyone who has accomplished such a task.

2) Is it possible to apply one's own styles as well as position the button specifically ?

I am currently rendering the button via the initcomplete portion of the code as that's the only way I got it to work. Any advice would be welcome. Thanks in advance :

  "initComplete": function() {
            oTable.buttons().container()
                .appendTo($('#collapse1'));
        }

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    The contents of any expanded rows are not shown in the exported PDF

    Unfortunately, at the moment there is no option in Buttons to include the child row information in the export. It might be possible to modify the button to add it, but to be honest, I suspect it would be easier to just write your own custom button that uses pdfmake or jsPDF to create the button based on information you get from the table.

    Is it possible to apply one's own styles as well as position the button specifically ?

    Your appendTo method is possibly the best option at the moment to be honest. This is a real weakness of DataTables at the moment that I plan to address in future.

    Regarding styling - absolutely you can apply your own CSS. You could use the existing stylesheet as a base, or use your browser's inspector to see the DOM structure used.

    Regards,
    Allan

This discussion has been closed.