Complex headers (column grouping) and sorting issue

Complex headers (column grouping) and sorting issue

AuricAuric Posts: 2Questions: 0Answers: 0
edited March 2011 in General
I have a table where I handle column grouping a little differently from the complex header example. In the example, TH elements that do not belong to a group are given a rowspan, but I have avoided that for aesthetic reasons. The thead looks something like this:

[code]



Group



Column 1
Column 2
Column 3
Column 4
Column 5


[/code]

In the resulting data table, sorting works fine everywhere except Column 5. Column 5 lacks the sorting classes, which are instead applied to the empty cell in the row above it.

Any thoughts on how I might work around this? Thanks.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    DataTables will take the first 'unique' element for the column, which is why it's the first TH for column 5 that is being used. There are two options off the top of my head:

    1. Swap the two TH elements for column 5 after DataTables has initialised
    2. Modify the DataTables core to take the last element for the column (probably not to hard - in the function _fnGetUniqueThs ).

    Allan
  • AuricAuric Posts: 2Questions: 0Answers: 0
    Modifying _fnGetUniqueThs worked perfectly. Thanks, Allan.
  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Nice one. I've put this on my list to have this as an optional initialisation switch in future.

    Regards,
    Allan
This discussion has been closed.