Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Tablefield creates tables with sticky header and currently it's not possible to disable those sticky headers.
Proposed resolution
Make it possible to pass 'sticky' property in variables of theme_tablefield_view() function. If 'sticky' is set, pass it along other variables for theme('table__tablefield').
After that, sticky table header can be disabled with:
function THEME_preprocess_tablefield_view(&$variables) {
$variables['sticky'] = FALSE;
}
Comment | File | Size | Author |
---|---|---|---|
#5 | sticky-header-before-after.png | 33.17 KB | SebasL |
#4 | option_to_disable_sticky-2816395-4.patch | 1.7 KB | lolandese |
#4 | Table violet.dev_.jpeg | 58.76 KB | lolandese |
#2 | make_it_possible_to-2816395-2.patch | 762 bytes | ilkkave |
Comments
Comment #2
ilkkave CreditAttribution: ilkkave at Druid for Yle - Finnish Broadcasting Company commentedHere's a patch to make this possible.
Comment #3
ilkkave CreditAttribution: ilkkave at Druid for Yle - Finnish Broadcasting Company commentedUpdating status.
Comment #4
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedAdded the option in the UI (see screenshot) so we don't need a theme hack.
Comment #5
SebasL CreditAttribution: SebasL as a volunteer commentedPatch applies cleanly.
After applying the patch, the checkbox for the sticky header is present in the manage fields section*
After un-checking the sticky header option and clearing the Drupal cache, the header does not stick to the top of the parent element as expected. See image below:
Also, when checking again the option, the header sticks to the top of the parent element on scroll as expected as well.
*Note: I understand why the setting was added in the manage fields section, as there are other settings related to the header, however it would make more sense to add it to manage display, because it is a display setting. For that maybe a new issue should be created.
Comment #7
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedComment #9
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedBased on the suggestion in the bottom of comment #5 we created a new issue at #2841782: Move display related settings from manage fields to manage display.
Comment #10
lolandese CreditAttribution: lolandese commentedFor D8 also create the sticky header (currently not the case), additionally making it optional.