Populating THEAD dynamically

Populating THEAD dynamically

John5788John5788 Posts: 9Questions: 0Answers: 0
edited December 2010 in General
Hello, is there a way to populate the contents of THEAD dynamically through DataTables? All I really see are functions for adding the data to the TBODY, but I require my table to have variable number of columns and I hope to achieve this by populating through DataTables.

Otherwise, I think my only other option is to write my own jQuery functions to grab JSON from server and write THEAD myself, then populate the TBODY using normal fnAddData() functions.

Replies

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    DataTables can create a THEAD element if there isn't already one in existence for the table, as shown in this example: http://datatables.net/examples/data_sources/js_array.html . However, the creation is quite limited - basically to creating single cells with text in them. If you want something a bit more advanced, just regular DOM / jQuery methods will do the trick.

    Allan
This discussion has been closed.