Refreshing table when data is from javascript object

Refreshing table when data is from javascript object

mikeosoftmikeosoft Posts: 40Questions: 14Answers: 2

Hi,
I populate the table with javascript object array. My app has an edit window (external to datatables) which modifies this javascript data.

In the past I used to refresh the table after an edit by calling initialization again. Now I can't do that because I use some other features that don't allow calling initialization after data has been added.

I did tried to call table.draw(false) and table.draw(true) that did nothing. The new data is not displayed.

Is there a simple method to refresh table data, beside doing what is described at http://datatables.net/tn/3 ?

Thanks a lot

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,948
    edited February 2019 Answer ✓

    Some options:

    1.If you can find the row in Datatables using row().data() you could update it using the same API with the new data then use draw().
    2. Use clear() to clear the table then rows().add() to had the updated JS object.
    3. Use the destroy option as noted in the link you provided.

    Kevin

  • mikeosoftmikeosoft Posts: 40Questions: 14Answers: 2

    Works like a charm , thanks!

This discussion has been closed.