Design, CG Graphics & Inspiration
TableSorter – jQuery plugin

TableSorter – jQuery plugin

TableSorter – jQuery plugin

tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell. It has many useful features including:

  • Multi-column sorting
  • Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. Add your own easily
  • Support for ROWSPAN and COLSPAN on TH elements
  • Support secondary “hidden” sorting (e.g., maintain alphabetical sort when sorting on other criteria)
  • Extensibility via widget system
  • Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+
  • Small code size

Getting started

To use the tablesorter plugin, include the jQuery library and the tablesorter plugin inside the tag of your HTML document:


tablesorter works on standard HTML tables. You must include THEAD and TBODY tags:

Last Name First Name Email Due Web Site
Smith John [email protected] $50.00 http://www.jsmith.com
Bach Frank [email protected] $50.00 http://www.frank.com
Doe Jason [email protected] $100.00 http://www.jdoe.com
Conway Tim [email protected] $50.00 http://www.timconway.com

Start by telling tablesorter to sort your table when the document is loaded:

$(document).ready(function()
{
$("#myTable").tablesorter();
}
);

Click on the headers and you’ll see that your table is now sortable! You can also pass in configuration options when you initialize the table. This tells tablesorter to sort on the first and second column in ascending order.

$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);

Note: tablesorter will auto-detect most data types including numbers, dates, ip-adresses

[DEMO] [DOWNLOAD]

  • Splashnology Editors,
  • May 20, 2009

SHARE THIS POST

This post has been written by the team here at Splashnology.com

Subscribe for the hottest posts

Subscribe to our email newsletter for useful tips and freebies.