Get header columns (also hidden)

Get header columns (also hidden)

tobiascapintobiascapin Posts: 1Questions: 0Answers: 0
edited October 2013 in General
Hi, I'm using this example: http://www.datatables.net/release-datatables/examples/api/row_details.html to add a details panel. I would like to get the header's labels to build automatically key-val couples.
I found oTable.fnGetData() but this doesn't work for header and, moreover, I can not use the dom inspection $("#table thead th") because if I hide some columns I lose that header. How to solve? Surely datatables has this informations inside its data.

Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It does, it just doesn't expose it via an API in 1.9.4-. So two options:

    1. you could use `fnSettings().aoColumns[i].sTitle` to get the title for column `i` - not really recommended since the settings object might change between versions

    2. Use DataTables 1.10, which is pre-beta. It does present this information via the API:

    [code]
    var table = $('#example').DataTable(); // note the capital D
    table.column( i ).header(); // gives the TH/TD cell for column i from which you can get the content
    [/code]

    I might add a `column().title()` API method into 1.10 thinking about it...

    Allan
This discussion has been closed.