Tablesorter demo
All options included, as well as the uitheme widget
by Mottie
HTML
<script src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script>
<script src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.widgets.js"></script>
<link rel="stylesheet" href="http://mottie.github.com/tablesorter/css/theme.jui.css">
<link rel="stylesheet" href="http://mottie.github.com/tablesorter/css/theme.bootstrap.css">
<link rel="stylesheet" href="http://mottie.github.com/tablesorter/docs/css/bootstrap.min.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/cupertino/jquery-ui.css">
<table class="tablesorter">
<thead>
<tr>
<th>AlphaNumeric</th>
<th>Numeric</th>
<th>Animals</th>
<th>Sites</th>
</tr>
</thead>
<tbody>
<tr><td>abc 123</td><td>10</td><td>Koala</td><td>http://www.google.com</td></tr>
<tr><td>abc 1</td><td>234</td><td>Ox</td><td>http://www.yahoo.com</td></tr>
<tr><td>abc 9</td><td>10</td><td>Girafee</td><td>http://www.facebook.com</td></tr>
<tr><td>zyx 24</td><td>767</td><td>Bison</td><td>http://www.whitehouse.gov/</td></tr>
<tr><td>abc 11</td><td>3</td><td>Chimp</td><td>http://www.ucla.edu/</td></tr>
<tr><td>abc 2</td><td>56</td><td>Elephant</td><td>http://www.wikipedia.org/</td></tr>
<tr><td>abc 9</td><td>155</td><td>Lion</td><td>http://www.nytimes.com/</td></tr>
<tr><td>ABC 10</td><td>87</td><td>Zebra</td><td>http://www.google.com</td></tr>
<tr><td>zyx 1</td><td>999</td><td>Koala</td><td>http://www.mit.edu/</td></tr>
<tr><td>zyx 12</td><td>0</td><td>Llama</td><td>http://www.nasa.gov/</td></tr>
</tbody>
</table>
JavaScript
$('table').tablesorter({
// *** APPEARANCE ***
// Add a theme - try 'blackice', 'blue', 'dark', 'default'
// 'dropbox', 'green', 'grey' or 'ice'
// to use 'bootstrap' or 'jui', you'll need to add the "uitheme"
// widget and also set it to the same name
// this option only adds a table class name "tablesorter-{theme}"
theme: 'jui',
// fix the column widths
widthFixed: false,
// Show an indeterminate timer icon in the header when the table
// is sorted or filtered
showProcessing: false,
// header layout template (HTML ok); {content} = innerHTML,
// {icon} = <i/> (class from cssIcon)
headerTemplate: '{content}{icon}',
// return the modified template string
onRenderTemplate: null, // function(index, template){ return template; },
// called after each header cell is rendered, use index to target the column
// customize header HTML
onRenderHeader: function (index) {
// the span wrapper is added by default
$(this).find('div.tablesorter-header-inner').addClass('roundedCorners');
},
// *** FUNCTIONALITY ***
// prevent text selection in header
cancelSelection: true,
// other options: "ddmmyyyy" & "yyyymmdd"
dateFormat: "mmddyyyy",
// The key used to select more than one column for multi-column
// sorting.
sortMultiSortKey: "shiftKey",
// key used to remove sorting on a column
sortResetKey: 'ctrlKey',
// false for German "1.234.567,89" or French "1 234 567,89"
usNumberFormat: true,
// If true, parsing of all table cell data will be delayed
// until the user initializes a sort
delayInit: false,
// if true, server-side sorting should be performed because
// client-side sorting will be disabled, but the ui and events
// will still be used.
serverSideSorting: false,
// *** SORT OPTIONS ***
// These are detected by default,
// but you can change or disable them
// these can...