Coder Social home page Coder Social logo

rpocklin / stickytableheaders Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jmosbech/stickytableheaders

0.0 1.0 0.0 220 KB

A jQuery plugin that makes large tables more usable by having the table header stick to the top of the screen when scrolling.

License: MIT License

stickytableheaders's Introduction

StickyTableHeaders

So what's it good for? Well, let's say you want to display a long list of fairly uniform tabluar data, like stock exchange listings or sport statistics but you don't want your users to get lost in the data as they scroll down on the page.

StickyTableHeaders to the rescue: By applying the StickyTableHeaders jQuery plugin to the table, the column headers will stick to the top of the viewport as you scroll down.

Go ahead and try out a demo.

The code is based on this proof of concept.

Usage

  1. Download the source from /js/jquery.stickytableheaders.js
  2. Include it in your project
  3. Initialize the plugin:
$('table').stickyTableHeaders();

###Tear down To remove the plugin:

$('table').stickyTableHeaders('destroy');

###Trigger an update

$(window).trigger('resize.stickyTableHeaders');

###Options The plugin supports one option, fixedOffset, which allows you to specify how much the sticky header should be offset from the top of the page. The fixedOffset parameter can either be a number or a jQuery object:

$('table').stickyTableHeaders({fixedOffset: $('#header')});

As described in pull request #33 responsive pages might need to re-initialize the plugin when the user resizes his browser. This is can be done by calling the plugin with the new options:

$('table').stickyTableHeaders({fixedOffset: [new-offset]});

Confused?

If any of this is confusing, please check out the /demo folder. There are a couple of examples in there. E.g. you can see how to use it with Twitter Bootstrap.

Future Work

  • Writing a better readme :)

Known Issues

  • Internet Explorer: You need to set the padding of the <th>s explicitly in the css in order to make the plugin work
  • Internet Explorer: Adding horizontal margin to the table causes the header to be misaligned when scrolling. (Issue #10)
  • border-collapse: collapse is not supported (issue #2)
  • Using the plugin together with tablesorter breaks in Internet Explorer 8

Browser Support

The plugin has been verified to work in:

  • Chrome 27
  • Firefox 20
  • Internet Explorer 8-10
  • Safari 5

NOTE: It does not work in Internet Explorer 7 (but it degrades nicely)

stickytableheaders's People

Contributors

jmosbech avatar alexbeletsky avatar floticerus avatar axelarge avatar krishnasagr avatar

Watchers

Robert Pocklington avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.