Total Rows and Primary Group Rows Missing in CSV, Excel, and PDF Exports
Total Rows and Primary Group Rows Missing in CSV, Excel, and PDF Exports
I'm picking up a project that uses DataTables and has buttons to export to csv, excel, and pdf. On the actual data table, it includes a "primary grouping" row for each subsection of the table, which can be clicked on and expanded to show all the rows for each section. It also has total rows which show the sums of the different fields of those child rows. This is showing in the actual data table. However, when I export to PDF, those rows go missing. Here is the logic I'm passing in for the PDF button, for example:
{
extend: 'pdfHtml5',
footer: false,
orientation: 'landscape',
title: '',
header: true,
filename: 'someName',
pageSize: 'LEGAL',
exportOptions: {
grouped_array_index: [0],
sumGrouping: false
},
action: function (e, dt, button, config) {
//Export the table.
var thisObject = this;
setTimeout(function () {
try {
$.fn.DataTable.ext.buttons.pdfHtml5.action.call(thisObject, e, dt, button, config);
} catch (e) {
console.error(e);
}
}
},
customize: function (doc) {
//By this point, doc.content[0].table.body is missing the primary group and total rows
//It does have all the other rows
}
}
This is what a "primary group" row looks like in the data table (not showing up on PDF):
<tr id="group-id-report-table-dlMnDaxXOa" class="primary-grouping 1_someReportName"><td colspan="3" class=" collapsed-group group-item-expander" data-group="1-someReportName" data-group-level="0">1. SomeReportName</td></tr>
And this is what a "regular row" looks like in the data table (showing up on PDF):
<tr role="row" class="odd group-item group-item-1-someReportName" data-group="1-someReportName" style="display: none;"><td>Name, Name</td><td>Date Range</td><td>0.00</td></tr>
There is another project that does almost this exact same thing and the PDF is working there, although I cannot pin down the difference. What are some of the issues that could cause these rows to go missing?
Notes:
1) The dataTables.buttons.js files are exactly the same in the project where the exports are working correctly and the one where it is not
2) The HTML for the DataTable renders exactly the same in the project where it is working and the one where it is not.
Answers
Hi @AZEberly ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin