Is it possible to create a data table without thead?

Is it possible to create a data table without thead?

RoyLingRoyLing Posts: 26Questions: 0Answers: 0
edited November 2012 in General
Can we do this? or how do we customize the plugin to do this?

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Yes it is possible - see this example: http://datatables.net/release-datatables/examples/data_sources/js_array.html . You must define the number of columns using aoColumns and set sTitle for each column so DataTables can insert the columns needed.

    Allan
  • RoyLingRoyLing Posts: 26Questions: 0Answers: 0
    Thanks Allan for the answer and example. As I learned and understood, a 'thead' is a must-have element in a dataTable, isn't it? Can we make it an optional one? that is - a table with only tbody and trs, no thead at all. Is it possible to do so? What I can imagine now is to hide thead elements in fnHeaderCallback.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > As I learned and understood, a 'thead' is a must-have element in a dataTable, isn't it? Can we make it an optional one?

    Fundamentally yes, a thead element is required. What would be the use case for not having one?

    It would be possibly to simple use something like `$('#example thead').detach();` to remove a built thead, but as I say, I'm not sure of the use case :-)

    Allan
  • RoyLingRoyLing Posts: 26Questions: 0Answers: 0
    edited November 2012
    Actually, I have a weird issue. I want to create a table with a complex table head, like the below:
    [code]


    R-Colgrp1
    R-Colgrp2
    ...


    R-Col1
    R-Col2
    R-Col3
    R-Col4
    R-Col5
    R-Col6
    R-Col7
    ...


    [/code]
    The THs in the 1st TR group the THs in the 2nd TR, but in my application, this head is dynamically created, not fixed.

    After checking all examples, I didn't get a clear way to use DataTables to handle this. Do you have any advise on this?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Yes - create the THEAD dynamically before you initialise the DataTable.

    Allan
This discussion has been closed.