fastest way to distroy and create a datatable

fastest way to distroy and create a datatable

ifaceiface Posts: 23Questions: 8Answers: 0
edited October 2010 in General
Hello

What's the fastest way to destroy and re-create a new dataTable?

I have a dataTable with about 100 - 200 rows. The aaData data is loaded via on page JSON. The starting point HTML I'm using is only the opening and closing TABLE tags.

I need to be able to replace the inited dataTable with a new dataTable that either:

1) Contains the same columns/functionality just a new JSON dataset.
OR
2) Is totally different and requires config from the ground up.

I've been using "bDestroy": destroy while re-initing the dataTable but it seems to take awhile especially on the 2nd our 3rd time around.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The quickest way is probably to wipe out the old table using innerHTML or something like that (removeChild perhaps) and then create a new table form the ground up - with a different ID. The Javascript garbage collector should then tidy up the mess left behind in memory, since there won't be any references to it. However... it's not particularly clean. Interesting that bDestroy should be slower for you after the first occasion - very odd! Do you have this available on a site I can see so I can profile it?

    Thanks,
    Allan
This discussion has been closed.