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.
By Sabino on
Is it possible to disable sticky table headers?
With enabled sticky table headers it really hurts to browse the modules-admin-page so I'd like to disable. I searched drupal.org and the web but everything I can find is about ENabling sticky table headers.
Comments
Sticky table headers disabled
Adding the following code to template.php disables sticky table headers.
Thanks!
Thanks!
Alternatively, if you want to
Alternatively, if you want to disable the sticky table header on a per table basis - instead of site wide, you can do the following.
1. Add an id or class to your table, e.g.
theme('table', $header, $rows, array('class' => 'no-sticky'));
2. Add JS to the page that will add the tableHeader-processed class to your table before the JS in tableheader.js has a chance to run. This will result in the table being skipped when Drupal.behaviors.tableHeader fires. e.g.
drupal_add_js('$("table.no-sticky thead").addClass("tableHeader-processed");', 'inline');
Note, the JS should be after the table is already on the page since the table must be evaluated by the browser before the JS runs. It's not sufficient to do on document ready since Drupal will process table headers first.
In reality, there needs to be a patch to theme_table that gives developers the option to turn it off.
nice solution. i added
nice solution. i added 'footer' for the scope to force the js to the bottom.
drupal_add_js('$("table.no-sticky thead").addClass("tableHeader-processed");', 'inline', 'footer');
This worked for me,
This worked for me, thanks!
Remember that you'll need to change table.no-sticky to be table.CLASS (where CLASS is the class of the table you want to affect). You could also use table#TABLEID to target one specific table.
Have I helped you? Consider buying me a beer.
It doesn't work out!
Hmmm... just copy paste, nothing happen.
PS: I swapped between themes and it worked in all the tables except for the modules one, weird. Anyway, thank's a lot, this is what I was looking for.
Another method for a global disable
As well as checking individual tables, tableheader.js also checks to see if the body has a class of tableHeader-processed so something like this should work too (this code is the D6 version):
Thanks a ton!!
Hey that worked for me...
thanks.
i have been going like crazy to find a remedy for days..
i also posted my question here http://drupal.org/node/896996
but no one answered because i didn't know what a sticky table was until today, when i created a view and went to formating options and saw the "Enable Drupal style "sticky" table headers (Javascript)" checkbox and my my head clicked!
regards
Baloch
Overwrite tableheader js function
Yet another method is to overwrite the Drupal.behaviors.tableHeader:
You can imagine how the settings could expanded to include some other options like list of matched paths etc. But as said in previous comments, these all are sort of hacks anyway. Should be handled by the core.
per-table non-js option
Another option is to modify the themed output HTML in your theme function to add the "tableHeader-processed" class to the thead element, eg:
This won't work if the thead element has any other attributes (but it also won't break horribly if it does). The core theme_table function doesn't add any attributes to the thead element so unless that has been overridden the above example should be fine.
theme_table sticky param
If you have control over the code that is calling theme('table') you can pass in a sticky variable.
True for D7, not applicable
True for D7, not applicable to D6, since it only checks if there is a header row.
Drupal 7
Here's how to do it in D7 :
Place this code in your theme's
template.php
Replace
THEME_NAME
with the name of your theme.The don't forget to clean your caches!!
--
wOOge | adrianjean.ca
+1
+1
subscibe
+1
Practice what you preach >> www.jawi-online.nl >> Full service internet bureau >>
Well done, works like a charm
Well done, works like a charm!