Replacing the tbody of a table then calling draw() is overwriting the new data with cached data.

Replacing the tbody of a table then calling draw() is overwriting the new data with cached data.

geraldhumphriesgeraldhumphries Posts: 2Questions: 1Answers: 0
edited July 2014 in Free community support

Example: http://live.datatables.net/deqalab/edit

I have converted a table in my application to use DataTables 1.10.1. There is a button on the table that will load new data into it by calling $("#table tbody").load(). The table does not display properly as it needs to be redrawn, as you can see if you comment out the draw() call in my example. However, calling draw() is overwriting the new data with the old. Is this a bug or is there something wrong with my implementation?

This question has an accepted answers - jump to answer

Answers

  • rhinorhino Posts: 80Questions: 2Answers: 17
    edited July 2014 Answer ✓

    I've modified your example so that it works, although you may not be pleased with how I've done it. I've also added a button so that you can visibly see the change happen.

    Do your table updates come to you as pre-formed HTML <tr> tags? If you can get the direct data, there are better ways to update the table, such as using the row.add() method.

  • geraldhumphriesgeraldhumphries Posts: 2Questions: 1Answers: 0
    edited July 2014

    Thanks. I've used a modified version of your example as my solution that doesn't require a wrapper class.

    http://live.datatables.net/sidahil/2/edit

  • rhinorhino Posts: 80Questions: 2Answers: 17

    Awesome! TIL what destroy() does, so thank you! :)

This discussion has been closed.