Destroying a datatable without restoring/redrawing the original
Destroying a datatable without restoring/redrawing the original
jerrosenberg
Posts: 7Questions: 0Answers: 0
Calling fnDestroy restores and redraws the original table it was based on. Is there a way to prevent this? In our case, we call fnDestroy on datatables before we remove them from the DOM to prevent leaking the element in the $.fn.dataTableSettings array. We really only need the line of fnDestroy that splices that array. The rest of it is just a performance hit right now, and it's very noticeable.
If there is no way to do this now, can you maybe add an option to fnDestroy called restoreOriginal or something? If we pass false, then all it would do is unwire the DT events and kill the settings reference?
If there is no way to do this now, can you maybe add an option to fnDestroy called restoreOriginal or something? If we pass false, then all it would do is unwire the DT events and kill the settings reference?
This discussion has been closed.
Replies
One option might be to copy the fnDestory function and trim it down to do just what you need only, and not restore the table to its full glory in plain HTML. This could be wrapped up in a plug-in API method.
Allan
In our app, this would be redundant, because we are hooking jquery's cleanData to call fnDestroy, so you are already in the process of a .remove, which will kill the events anyway.
I will try to put this into a plug-in. I just wasn't sure if this is a common case, if you'd want this in the main library. Plus then we wouldn't have to maintain it between versions :)
Thanks.