create a table with 1 column containing 2 headers

create a table with 1 column containing 2 headers

mkoryakmkoryak Posts: 14Questions: 0Answers: 0
edited July 2011 in DataTables 1.8
i am trying to do this:
http://i.imgur.com/EGr3m.png

i build the thead myself and let datatables draw the tbody. what ends up happening is that i get 2 cells, one under 'city', and one under 'state', whereas i want to have a single column under 'origin'


is it possible to do this without adding a hidden 3rd header row which will contain a cell of colspan 2 under these 2 cells?

Thanks

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    Others can correct me if I'm wrong, but I don't think you can do that.

    You can do the opposite, where you have a header span more than one column (as long as you have another header row that defines one-per-each-column), but I don't think you can do what you want, which is in effect making the data column span 2 columns. (Allan shows an example of this on his blog: http://www.datatables.net/blog/Creating_beautiful_and_functional_tables_with_DataTables)

    Would a happy compromise to just list the header as "City, State"? or use divs/spans within the header cell to give them a close appearance, with a border between them?
  • mkoryakmkoryak Posts: 14Questions: 0Answers: 0
    fbas:
    That is very unfortunate if i cannot do that. I am converting a different table implementation that supports this, and it would be a show stopper if i cant hack datatables to do this.

    what about my original idea of adding a 3rd 1px high header row with the column widths i require?
    This will probably break sort listener binding, but i can probably fix that by manually binding the sort listeners via the sort API.
This discussion has been closed.