Export buttons do not export changed data

Export buttons do not export changed data

artycoartyco Posts: 4Questions: 1Answers: 0

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

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    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 use row().invalidate() (if you have a row-selector you can use to choose the right row) or rows().invalidate() to invalidate all - might be inefficient.

    Kevin

  • artycoartyco Posts: 4Questions: 1Answers: 0

    Thank you very much, finally the solution was rows().invalidate(), as you suggested

Sign In or Register to comment.