How do I set the column headers dynamically?

How do I set the column headers dynamically?

maxorelusmaxorelus 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

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    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

  • allanallan Posts: 62,313Questions: 1Answers: 10,225 Site admin

    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

  • maxorelusmaxorelus Posts: 3Questions: 2Answers: 0

    Thank you, this helped a bunch!

This discussion has been closed.