Published:

May 21, 2008

JQuery Plugin - Readable Tables

On occasion tables still have to be used (for table data only of course)...

On occasion tables still have to be used (for table data only of course) but when you're talking about a large amount of data it becomes messy and arkward to read (especialy if it scrolls beyond the browser height).

Recently we have been faced with converting such a table in to something more useable (take a look at the outcome here) and from that we made a little jquery plugin to do some nice table highlighting.

There are two types of table hightlighting, simple and complex. 

The simple method just highlights the row your hovering over and all you need to do is create a table with a class of 'simple_table' (by default but can be over ridden) and rows with a class of either 'row1' or 'row2' and then in your document ready function call you just have to do $('#id of containing element').tablehighlight();

The complex version does some clever column highlighting as well as row highlighting:

  • hover over a column heading the entire column will be highlighted
  • hover on a row heading and the entire row will be hightlighted
  • hover on a table cell and the cell is highlighted along with both the row header and column header.

The structure of the html is very similar but has the following differences:

  • the table has the class 'complex_table'
  • there is an extra row with the class of heading (this row is for your column headers)
  • each th in the heading row has a class which is used by every td in that column
  • inside the row1 and row2 tr's there is now a th (this is the row header)
  • each td has a matching class with the column it is in.

All the jquery does is add some extra css classes to the relevant places so it's nice and degradable. If fancy a play you can download all the files in zip including some basic examples or you hop over the jQuery project page for a read.

Lets Talk

Leave your phone number or email address below and we will contact you back

Or you can call us on 0121 288 2296