Adding columns: destroy & create is still the right way?
Adding columns: destroy & create is still the right way?
I have a case where the user selects a date range and hits a button, at which point I want to fill a table with a few columns of data which will always be there, and then one column per month in the date range. (At the point where I'm making the Ajax request to get the data, I know how many columns I'm requesting; I don't have to wait for the results from the server.)
Here's what I've found on this:
- This question from 2011 says to
fnDestroy()
the table and recreate it. - This question from January has
destroy()
instead offnDestroy()
; I assume I should use that instead? There's not some API for adding/removing columns?
(For a variable number of columns--the initial/default display is something goofy like 60 columns--it seems like the FixedColumns extension is pretty much a requirement, but they also want child rows, which are not compatible with FixedColumns. I haven't decided which one I'm going to go with... I might just create an empty second table for the child rows, and populate that when they select a row in the "parent" table.)
This question has an accepted answers - jump to answer
Answers
Yes. DataTables does not have an API to dynamically add and remove columns at this time.
Allan