I found a better workaround for this… which you can see below.
But first, to put it into context…
We have a table showing say… 100 records. The user wants to be able to scroll horizontally to see all records. However, since we are also displaying lots of records, the user has to scroll to the bottom of the page to find the horizontal scrollbar. This isn’t ideal, because then he cannot look at the top/middle records.
So… even a top scrollbar wouldn’t have worked, so I decided to use a “floating” scrollbar instead. I found a solution and implemented it in minutes, and it works beautifully!
Here are the steps (and code):
1) Download the JS from here.
2) Upload it to your server (at your own discretion). I uploaded mine to a “js” folder in the root.
3) Add the following code to a custom plugin…
Note: In my example I am selective on what Admin page I wanted to use it (i.e. the Posts List page for the “projects” CPT). You don’t have to be.
<?php
/* START: Loads floating scrollbar JS */
function cc_load_floating_scrollbar() {
global $pagenow;
if ( is_admin() && $pagenow=='edit.php' && 'projects' === $_GET['post_type']) {
wp_enqueue_script( 'cc_floating_scrollbar', '/js/jquery.ba-floatingscrollbar.js' );
}
}
add_action( 'admin_enqueue_scripts', 'cc_load_floating_scrollbar' );
/* END: Loads floating scrollbar JS */
/* START: Attaches floating scrollbar to Projects List Table */
function cc_attach_projects_list_table_to_floating_scrollbar() {
echo "<script type='text/javascript'>";
echo " ( function ( $ ) {";
echo " $( document ).ready( function () {";
echo " $('.acp-overflow-table table.wp-list-table.fixed').floatingScrollbar();";
echo " });";
echo " }( jQuery ) );";
echo "</script>";
}
add_action( 'admin_head', 'cc_attach_projects_list_table_to_floating_scrollbar' );
/* END: Attaches floating scrollbar to Projects List Table */
?>