Export and Print for RowGroup Extension
Export and Print for RowGroup Extension
daytonoutar
Posts: 25Questions: 7Answers: 1
I have taken note of the option of using the source code found at https://datatables.net/forums/discussion/42916/row-grouping-with-printing#latest. However, I'm hoping there is another simpler way to have the printing and exporting features of the Button extension able to print and export row grouping.
See below screenshot of RowGroup working on screen
See below screenshot of same datatable when Print is chosen
This question has an accepted answers - jump to answer
Answers
Sorry no. The RowGroup extension doesn't play nicely with the export options at the moment (see the compatibility chart). That is something I hope to address in future.
Nice styling on the row grouping btw!
Allan
Thanks.
I'm just going to make a print.css to print this much needed categorization.
Good work on the progress you have made on DataTables.
Do you have news to print with group?
Nope, there's been no progress. It's in the backlog but isn't a priority right now, I'm afraid.
I couldn't get the code listed at https://datatables.net/forums/discussion/42916/row-grouping-with-printing to work properly, but with a little tweaking do have a working solution for exporting datatables with row grouping.
As in that thread:
Usage:
Define grouped_array_index in exportOptions
New logic in _exportData in datatable-buttons.js:
For completeness, the entire function _exportData in datatable-buttons.js can be replaced with:
Nice, thanks for sharing.
Colin
bubomuke, you rock! Your code works great on my solution.
Just one thing, I'm trying to make the grouped header indent. I tried using the customize setting on the button, but it doesn't seem to take. Any suggestions?
Hey @bubomike ,
I tried your code for exporting the group row but it is not working as you explain. I replaced the _exportData in datatable-buttons.js with your code. but I am still confuse with this code
exportOptions: {
// Any other settings used
grouped_array_index: <place row to use here>,
},
how to pass value grouped_array_index: 2 or grouped_array_index:'Office'. I am binding data with Ajax.
Can you show the steps to replace the code with demo?
Thank you in advance.
@sarooptrivedi
I paste this code in datatables.js (_exportData function) and
use grouped_array_index: "office"
This will export group rows only.
what about sums and avgs, whatever we used with rowGroup to display summarized data??
There are a few threads discussing exporting the RowGroup headers, such as here and here. Hopefully that'll help,
Colin
I'm loading datatables.js using the download builder to get the documents from the CDN. Does this solution work if I include the new function in a different file or do I have to replace the specific lines in datatables.js?
You would need to replace the file with that change, I'm afraid.
Colin
Answering myself: I downloaded the combined file from this site & made the changes per this post & it is working as described. Can anyone direct me to documentation that iterates through the settings available for customizing the pdf file?
The
pdfhtml5
docs provide the details. You will want. to refer to the PDFMake docs also.Kevin
i just cant get this printing to work in pdf printing.