on reload of aaData I am getting multiple dataTables_wrapper, length, filter

on reload of aaData I am getting multiple dataTables_wrapper, length, filter

RicklRickl Posts: 6Questions: 0Answers: 0
edited November 2009 in General
I have a number of javascript arrays and I want to swap them into an existing dataTable object as required.

But when I reload a dataTable object with new data I get multiple dataTables_wrappers, dataTables_lengths, dataTables_filters etc.

This creates a 'nested' look - every time I reload aaData I get another datatTables wrapper complete with another set of features wrapped around the table.

I thought I could setup a dataTable, keep a reference to it, and then reload it by resetting aaData. And it does work, I see the new table data but I get a new copy of all the features too. I tried calling .fnClearTable() before reloading the table but that did not seem to have any effect. I tried setting the object to null and then completely reinitializing it but still got the duplicate html elements.

Looking at the generated source after doing the initial setup and one reload I see this in the html.


Show

Replies

  • allanallan Posts: 61,797Questions: 1Answers: 10,115 Site admin
    Hi Rickl,

    It sounds like you are re-initialising DataTables multiple times (i.e. calling $.dataTable() more than once), which is what is causing you problems. What you can to to swap data around is make use of the fnClearTable() and fnAddData() API functions that DataTables provides: http://datatables.net/api

    Regards,
    Allan
  • RicklRickl Posts: 6Questions: 0Answers: 0
    Haha! So obvious - when you point it out!
    Thank you.
This discussion has been closed.