While the core theme_table does not support multi-row headers, it can fairly easily be adapted to do so. By trivially changing tableheader.js, multi-row headers would be supported. To properly set the width of the sticky header table, only 1 row of headers should have their widths specified.
The two changes would be to add ":first" to the jQuery specifier in Drupal.tableHeader:
this.originalHeaderCells = this.originalHeader.find('> tr > th'); // existing
this.originalHeaderCells = this.originalHeader.find('> tr:first > th'); // improved
// ... and
this.stickyHeaderCells = this.stickyHeader.find('> tr > th'); // existing
this.stickyHeaderCells = this.stickyHeader.find('> tr:first > th'); // improved
I know that stick tables are being completely rewritten (and hopefully more functional) for D8, so I'm not sure if this change would apply to D8 as well.
The last bit would be to enhance theme_table to support multi-row headers. These are useful (via colspan) to group columns in a meaningful way. But that's a separate issue....
Comment | File | Size | Author |
---|---|---|---|
#12 | 2039937-12--multi_row_sticky_table_header.patch | 594 bytes | drunken monkey |
#2 | 2039937-2-multi_row_sticky_table_header--d7--do-not-test.patch | 665 bytes | drunken monkey |
Comments
Comment #1
nod_sticky headers are marginalized in D8 (it's not on by default anymore). And the script has already been optimized in D8 so you can have a look if that'll work there too.
Comment #2
drunken monkeyIt's hard to test in D8, since there isn't really a module (I know of) yet that adds a second header row, but I've also run into this problem in D7. I also tried to solve it the same way you did – but I found this sometimes leads to wrong results in Chrome.
My new solution, as can be seen in the attached patches, seems to work fine across all browsers, however. Would be great if you could test it to see if it works for you, too – and if we could maybe get this committed in some Drupal version.
Comment #3
joelpittetSince this is a feature request I'll bump to 8.1.x and postponing on that branch opening. Sorry this didn't get in, it looks quite a simple solution if that's all it is.
Comment #4
droplet CreditAttribution: droplet commentedAs my understand of HTML5 SPEC, we can't have 2 `thead` in HTML.
(I can be wrong.)
Comment #5
joelpittetI'm quite sure that's true but you can put in two rows in the thead.
Comment #11
joelpittetPostponed isn't the right status for this, moving back to active. It was really postponed on the release.
Comment #12
drunken monkeyThanks for bumping, here's also a re-roll.