How do I set the column headers dynamically?
How do I set the column headers dynamically?
maxorelus
Posts: 3Questions: 2Answers: 0
Hi,
This table library is great! I was able to populate the table data with a js object, but I haven't been able to find how to set the column headers for the table. I've seen examples of populating those fields by hard coding them in, but I haven't seen any mention of dynamically populating those spaces. Could anyone point me in the right directions?
Thank you
This discussion has been closed.
Answers
So when you say hardcoded, do you mean in the html?
You could optionally use the
columns
setting, and write some jQuery prior to the table initialization to populate a columns variable.But if youre looking for something like this, then thats not currently possible
Column headers can be created by DataTables using the
columns
option as jLinux says. That array can easily be dynamically defined if you require (although it can't change after initialisation), or it can be hardcoded like in many of the examples.Allan
Thank you, this helped a bunch!