I am interested in user-generated content being able to make use of the feature in tableheader.js (the table header persists at the top of the window as the reader scrolls down through a long table—as seen in various tables on the administration pages).

Other than the table having the sticky-enabled class on the tables in the user-generated content, what is required in the theme to include the tableheader.js on pages when required?

I hoped that I could just refer to it with a scripts[]= line in the theme.info file, but I haven't figured out how to do that since the tableheader.js file isn't within the theme's directory.


cmcqueen1975’s picture

I'm still interested in any advice anyone can offer on using Drupal's tableheader.js in user content.

This question is related to:

auberdjinn’s picture

If you're still interested, I added this script using drupal_add_js() in the theme's template.php thus:

drupal_add_js('misc/tableheader.js', 'core');

ge’s picture

I did not find any simple way to enable this on arbitrary tables. It appears there is a large amount of additional HTML to attach the "sticky-header" class to a copy of the table header, plus the "sticky-enabled" and "sticky-table" classes to the table, which you would not want to be going in and manually adding to your users' table HTML each time.

However, if I create a new content type with CCK and then go in Views to create a view, I find that if the display format is set to Table rather than unformatted, I magically get this option:
Enable Drupal style "sticky" table headers (Javascript)

You could create an all-purpose "Table" content type and set up a corresponding View, selecting the sticky table header option. Then whenever your content creators want their tables to have sticky headers, they select "Table" in the Create Content options.

Genny Engel

schildi’s picture

Please explain more in detail what you did to achieve sticky table header by views. Where do I find this option?
I also struggled with views and class "sticky-enabled", but with no avail (compare http://drupal.org/node/1045486).
What I tried is to embed a default-view in an "ordinary" page. File tableheader.js is included, class "sticky-enabled" is assigned to a div surrounding the views table. I also tried to assign the css class to the table by manipulating the html code in firebug. But nothing happens.