Using Buttons plug-in to export table with dynamically added data?
Using Buttons plug-in to export table with dynamically added data?
pamelafox
Posts: 1Questions: 1Answers: 0
Ahoy! I'm using DataTables with the Buttons extension with the hope of being able to easily copy-to-spreadsheet the contents of my table. However, it's a table that the user modifies on the fly, with contenteditable cells.
Is it possible for exportData() to get the most recent data? (I saw an old post that seemed to say no, but I want to double check, since it seems like an oft-desired use case).
Thank you!
This discussion has been closed.
Answers
This gives an example of using export buttons.
https://editor.datatables.net/examples/extensions/exportButtons.html
In this example you can make changes and use the export button and see that the export is of the current table.
Kevin
This is the key part here. You need to tell DataTables that the data has changed since otherwise it will used cached values. You can use the API methods
row().data()
orcell().data()
to set data directly. Or userow().invalidate()
orcell().invalidate()
to have DataTables read the data from the HTML that has been changed.Allan