Export buttons do not export changed data
Export buttons do not export changed data
I am using buttons to export the data to PDF, and excel; It works very well; but if I make changes to the table data, by javascript, without regenerating the table, the original data is exported, not the updated one.
Is there anything I can do to export the data as it is displayed on the screen?
You can easily test this, I have assembled the following example:
https://codepen.io/artyco/pen/OJvRwMp
Just click on the blue button, notice that the first row changes, and then export to excel (or another button), you will see that the original data has been exported, not the modified one.
Any ideas?
Thank you very much, regards
Esteban
This question has an accepted answers - jump to answer
Answers
The problem is you are directly updating the HTML which Datatables does not know about. You can use something like
cell().data()
to update the row data. Or you can continue using the technique you have and userow().invalidate()
(if you have arow-selector
you can use to choose the right row) orrows().invalidate()
to invalidate all - might be inefficient.Kevin
Thank you very much, finally the solution was
rows().invalidate()
, as you suggested