Add or remove column dynamically
Add or remove column dynamically
dspoonia7
Posts: 16Questions: 0Answers: 0
Hi Alan,
Is it possible in latest version 1.10.11, to add / remove columns from the table dynamically.
This discussion has been closed.
Replies
You can chance a column's visibility dynamically, but you can't actually add and remove columns I'm afraid.
Allan
Thanks Alan for quick reply.
But I have like hundreds of columns and user usually picks only 10 columns at once. So instead of loading all the columns in browser and make it slow, what i have done is I have custom show/hide column settings. When user update columns, I refresh the table with new columns. Will try some more things.
I could have used server side rendering but that is too complicated in backend side :P
Thanks anyways!!
Hey Alan
Can I use https://datatables.net/reference/api/destroy() method to make it work?
I need to render different set of columns without reloading the page. Is that possible somehow?
Yes -
destroy()
will work. You need to destroy the old table and then create the new one and initialise that.Adding and removing columns dynamically from a DataTables during "runtime" is not possible (I should have qualified that above).
Allan
Hey Alan, finally did it.
Followed a fiddle solution https://jsfiddle.net/cr78t379/3/
Thanks!!
Super. Thanks for posting back with your solution!
Allan