Excel export options: Selected modifier behaves different than documented
Excel export options: Selected modifier behaves different than documented
Hi,
according to manual, you can choose if the Excel export included selected rows only or all rows:
"As of Buttons 1.5.0 the exported data from this method will automatically attempt to determine if any rows in the table are selected. If they are, the export will be restricted to this those rows. If no rows are selected, the full data set will be exported."_
Source: https://datatables.net/reference/api/buttons.exportData()
My Excel export options config looks like this:
modifier: {
order: 'current',
page: 'all',
selected: false,
},
The table is configured to allow selection of a single row:
select: {
style: 'single'
},
When exporting to Excel, the selected row is NOT exported. When un-selecting the selected row, all rows are exported.
Looks like a bug to me. Questions:
- Is this a bug?
- If so, any idea for workaround? I tried to un-select the selected row before exporting, but did not find the right event where to intervene before the export occurs.
Thanks for your help!
Replies
selected: false
means that only rows which are not selected will be exported. Valid values arefalse
(export unselected rows),true
(export selected rows) andnull
- default.There was a bug in this area, it would be worth trying the nightly versions of both Buttons and Select if it is still causing you issues.
If even with the nightly's you are having problems, can you give me a link to a page showing the issue please?
Allan
Hi Allan,
thanks for your help.
This is the observed behaviour of the selected parameter:
I tried using the nightly build for buttons and selected extensions using these references:
Unfortunately, the export button did not show up (print and columns visibility buttons worked fine).
The table in question can be found here:
https://dividendstocks.cash/growth-screener
To use export, you need to register and I need to promote you to full member then.
Regards,
Torsten
You need the Select nightly for it to work. I've put a little test case together here: http://live.datatables.net/korezaha/1/edit .
Note that I've also include pdfmake and jszip to allow the Excel and PDF buttons to work.
Allan
Sorry - I lost selected nightly in copy & paste process. Anyway, thanks for the sample. Let's got with this. When testing, I am not able to export all rows - regardless if selected or not.
My expectation: Not setting the selected parameter means to ignore if the row is selected or not and just export all rows. Is this what you expect, too?
Furthermore, setting the "selected: false" results in exported the selected rows only, like "selected: true" does. Doesn't feel right and looks like a second issue to me (see code sample below).
Regards,
Torsten
===
I selected 2 rows. Expectation: these 2 rows are not exported, but the other rows are.
Result: Only 2 selected rows are exported.