Original Author: Christian Bach
Maintainer of this fork: Rob Garrison (Mottie)
Version: 2.31.3 (changelog
Licence: Dual licensed under MIT or GPL licenses (pick one).

Contents

  1. Introduction
  2. Demo
  3. Getting started
  4. Examples
  5. Configuration
  6. Widget & Pager Options (v2.1)
  7. Methods
  8. Events
  9. API
  10. Download
  11. Compatibility
  12. Support
  13. Credits

Introduction

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:

Demo

Account #
First Name
Last Name
Age
Total
Discount
Difference
Date
A42b Peter Parker 28 $9.99 20.9% +12.1 Jul 6, 2006 8:14 AM
A255 Bruce Jones 33 $13.19 25% +12 Dec 10, 2002 5:14 AM
A33 Clark Evans 18 $15.89 44% -26 Jan 12, 2003 11:14 AM
A1 Bruce Almighty 45 $153.19 44.7% +77 Jan 18, 2001 9:12 AM
A102 Bruce Evans 22 $13.19 11% -100.9 Jan 18, 2007 9:12 AM
A42a Bruce Evans 22 $13.19 11% 0 Jan 18, 2007 9:12 AM

TIP! Sort multiple columns simultaneously by holding down the Shift key and clicking a second, third or even fourth column header!

Getting started

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

<!-- choose a theme file -->
<link rel="stylesheet" href="/path/to/theme.default.css">
<!-- load jQuery and tablesorter scripts -->
<script type="text/javascript" src="/path/to/jquery-latest.js"></script>
<script type="text/javascript" src="/path/to/jquery.tablesorter.js"></script>

<!-- tablesorter widgets (optional) -->
<script type="text/javascript" src="/path/to/jquery.tablesorter.widgets.js"></script>

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

<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Due</th>
<th>Web Site</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smith</td>
<td>John</td>
<td>jsmith@gmail.com</td>
<td>$50.00</td>
<td>http://www.jsmith.com</td>
</tr>
<tr>
<td>Bach</td>
<td>Frank</td>
<td>fbach@yahoo.com</td>
<td>$50.00</td>
<td>http://www.frank.com</td>
</tr>
<tr>
<td>Doe</td>
<td>Jason</td>
<td>jdoe@hotmail.com</td>
<td>$100.00</td>
<td>http://www.jdoe.com</td>
</tr>
<tr>
<td>Conway</td>
<td>Tim</td>
<td>tconway@earthlink.net</td>
<td>$50.00</td>
<td>http://www.timconway.com</td>
</tr>
</tbody>
</table>

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

$(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.

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

NOTE! tablesorter will auto-detect most data types including numbers, dates, ip-addresses for more information see Examples.

Examples

These examples will show what's possible with tablesorter. You need Javascript enabled to run these samples, just like you and your users will need Javascript enabled to use tablesorter.

Basic

Sorting

Theming

Using Parsers / Extracting Content


Advanced

Parsers / Extracting Content

Widgets / Plugins

Adding / Removing Content

Change Header Style


Other

Options & Events

Metadata - setting inline options

Demos

Playgrounds & Other demos

Plugins / Widgets
these widgets are included in the jquery.tablesorter.widgets.js file (except for extra filter formatter functions).
this widget is included with the plugin core.

Custom Parsers

Work-in-progress


Configuration

tablesorter has many options you can pass in at initialization to achieve different effects
TIP! Click on the link in the property column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
Property
Type
Default
Description
Link
Property Type Default Description Link
cancelSelection Boolean true Indicates if tablesorter should disable selection of text in the table header (TH). Makes header behave more like a button.
String "" Additional CSS class applied to style the header with a ascending sort (v2.11).
cssChildRow String "tablesorter-childRow" Add this css class to a child row that should always be attached to its parent. Click on the "cssChildRow" link to toggle the view on the attached child row. Previous default was "expand-child" (Modified v2.4). 1 2
String "" Additional CSS class applied to style the header with a descending sort (v2.11).
String "" Additional CSS class applied to style the headers (v2.11).
String "" Additional CSS class applied to style the header row (v2.11).
String "tablesorter-icon" The CSS style used to style the header cell icon (modified v2.7; v2.21.1).
String "" The CSS style added to the header cell icon when the column has an ascending sort (v2.18.3).
String "" The CSS style used to style the header cell icon when the column has a descending sort (v2.18.3)
String "" The CSS style used to style the header cell icon when the column sort is disabled (v2.28.13)
String "" The CSS style used to style the header cell icon when the column does not have a sort applied (v2.18.3)
String "tablesorter-ignoreRow" Class name to add to a table header row if you want all cells within this row to be ignored (v2.18.4). 1 2
String "tablesorter-infoOnly" All tbodies with this class name will not have its contents sorted. (v2.2).
String "" Additional CSS class applied to style the header when no sort is applied (v2.15).
cssNoSort String "tablesorter-noSort" Class name added to element inside header. Clicking on that element, or any elements within it won't cause a sort. (v2.20.0).
String "" Additional CSS class applied to style the header cell while it is being sorted or filtered (v2.4; v2.11).
String "mmddyyyy" Set the date format. Here are the available options. (Modified v2.0.23). Example
Boolean or String false Set this option to provide useful for development debugging information in the console Updated v2.30.0. Example
delayInit Boolean false Setting this option to true will delay parsing of all table cell data until the user initializes a sort. This speeds up the initialization process of very large tables, but the data still needs to be parsed, so the delay is still present upon initial sort. Example
Boolean true Any colspan cells in the tbody may have its content duplicated in the cache for each spanned column (v2.25.0; v2.25.8). Example
String "bottom" Option indicating how tablesorter should deal with empty table cells. (Modified v2.1.16, v2.16.2). Example
Object null An object of instructions for per-"header cell" controls in the format: headers: { 0: { option: setting }, ... } (v2.17.1) 1 2 3 4 5
String "{content}" This is a template string which allows adding additional content to the header while it is being built (v2.7; v2.17.8). Example
ignoreCase Boolean true When true, text sorting will ignore the character case. If false, upper case characters will sort before lower case. (v2.2).
Function null This callback fires when tablesorter has completed initialization. (v2.2).
Boolean true Apply widgets after table initializes (v2.3.5).
String undefined This option should contain a unique namespace for each table; it is used when binding to event listeners (v2.15.7).
Function null Replace the default number sorting algorithm with a custom one using this option (v2.12).
Function null This function is called after content is to the TH tags (after the template is procressed and added). You can use this to modify the HTML in each header tag for additional styling (v2.18.0). Example
Function null This function is called after the template string has been built, but before the template string is applied to the header and before the onRenderHeader function is called (v2.7). Example
String "click" Use this option to change the click event (v2.22.0)
String "mousedown" Use this option to change the pointer down event (v2.22.0)
String "mouseup" Use this option to change the pointer up event (v2.22.0)
Boolean true When this option is true any applied sort on the table will be reapplied after an update method (v2.19.0).
String "> thead th, > thead td" jQuery selectors used to find cells in the header.
String "tr.remove-me" This CSS class name can be applied to all rows that are to be removed prior to triggering a table update. (v2.1).
selectorSort String "th, td" jQuery selector of content within selectorHeaders that is clickable to trigger a sort (v2.4). Example
serverSideSorting Boolean false Set to true if the server is performing the sorting. The ui and events will still be used (v2.5.3).
showProcessing Boolean false Show an indeterminate timer icon in the header when the table is sorted or filtered. Please note that due to javascript processing, the icon may not show as being animated. I'm looking into this further and would appreciate any feedback or suggestions with the coding (v2.4). Example
Array or Object null Use to add an additional forced sort that will be appended to the dynamic selections by the user (v2.24.0). Example
Array null Use to add an additional forced sort that is prepended to sortList. Example
String "asc" This sets the direction a column will sort when clicking on the header for the first time. Valid arguments are "asc" for Ascending or "desc" for Descending.
1 2
Array null Use to add an initial sort to the table. Example
Boolean false Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. (Modified v2.2). Example
String "shiftKey" The key used to select more than one column for multi-column sorting. Defaults to the Shift key. Example
Boolean false Setting this option to true will allow you to click on the table header a third time to reset the sort direction. (v2.0.27). Example
sortResetKey String "ctrlKey" The key used to reset sorting on the entire table. Defaults to the control key. The other options are "shiftKey" or "altKey" (reference).
sortRestart Boolean false Setting this option to true will start the sort with the sortInitialOrder when clicking on a previously unsorted column. (v2.0.31). Example
Boolean false Setting this option to true and sorting two rows with exactly the same content, the original sort order is maintained (v2.14). Example
String "max" A key word indicating how tablesorter should deal with text inside of numerically sorted columns. (v2.1.16). Example
tabIndex Boolean true Add a tabindex to the headers for keyboard accessibility; this was previously always applied (v2.14).
String "" Additional CSS class applied to style the table (v2.11).
String "data-text" This data-attribute can be added to any tbody cell and can contains alternate cell text (v2.16.0).
Multiple* "basic" Defines which method is used to extract data from a table cell for sorting (v2.19.0) Example
Function null Replace the default sorting algorithm with a custom one using this option (v2.27.6) - *NOTE* The parameters have changed!!. 1 2
String "default" This option will add a theme css class name to the table "tablesorter-{theme}" for styling (v2.4; v2.18.0). Example
Boolean true Indicates how tablesorter should deal with a numerical format: (v2.1.3). Example
String "widget-{name}" When the table has a class name that matches the template and a widget id that matches the {name}, the widget will automatically be added to the table (v2.18.0)
Object { } In version 2.1, all widget options have been moved into this option. This is a move to store all widget specific options in one place so as not to polute the main table options. All current widgets have been modified to use this new option. (v2.1). Example
widgets Array [ ] (empty array) Initialize widgets using this option ( e.g. widgets : ['zebra'], or custom widgets widgets: ['zebra', 'myCustomWidget'];, see this demo on how to write your own custom widget ). Example
Boolean false Indicates if tablesorter should apply fixed percentage-based widths to the table columns (modified v2.4). Example
Utility Options
String "checked" Used by the "checkbox" parser in the parser-input-select.js file (v2.22.2; v2.25.0). Example
Boolean true Used by the "checkbox" parser in the parser-input-select.js file (v2.24.6). Example
data Object, Array undefined Storage for processed table build widget (widget-build-table.js) data (array, object, string) (v2.11). Example
dateRange Numeric 50 Used by the two digit year parser (parser-date-two-digit-year.js) to set the date range (v2.14). Example
object null This option is used by multiple parsers to localize the language (v2.24.0; v2.24.1). 2 2
Boolean false Used by the input-select parser indicate if changes to child row content is to be ignored (v2.28.10)
String "alt" Used by the image parser to grab the image attribute content (v2.17.5; moved to tablesorter core in v2.18.0; see config.parsers).
Deprecated/Removed Options
String This option was removed! It has been replaced by cssNoSort which does the opposite of what this class name was supposed to do.
String undefined This option is being deprecated in v2.21.3! It has been replaced by widgetOptions.storage_fixedUrl; but is still available for backwards compatibility.
This option was removed in v2.21.2! It has been replaced by widgetOptions.columns.
This option was removed in v2.4! It has been replaced by widgetOptions.uitheme.
This option was removed in v2.4! It has been replaced by widgetOptions.zebra.

Widget & Pager Options

Widget Priority
Name
Requires jQuery
Limiting function
10uithemev1.2.6
20saveSortv1.4.11.4.1 (parseJSON)*
30columnsv1.2.6
40resizablev1.4.1*1.4.1 (parseJSON)*
50filterv1.4.31.4.3 (nextUntil & delegate)
55pager widgetv1.71.7 (on)
60stickyHeadersv1.4.31.4.3 (isWindow)**
90zebrav1.2.6
Lastpager pluginv1.2.6

tablesorter widgets have many options, and to better organize them, they now are grouped together inside of the widgetOptions. Thanks to thezoggy for putting together this jQuery-widget compatibility table, but please note:
TIP! Click on the link in the property column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
Property
Type
Default
Description
Link
Property Type Default Description Link
Array [ "primary", "secondary", "tertiary" ] Columns widget: When the column styling widget is initialized, it automatically applied the default class names of "primary" for the primary sort, "secondary" for the next sort, "tertiary" for the next sort, and so on (add more as needed)... (Modified v2.1). Example
Boolean true Columns widget: If true, the class names from the columns option will also be added to the table tfoot (v2.4). Example
Boolean true Columns widget: If true, the class names from the columns option will also be added to the table thead (v2.4). Example
String or Array "" Filter widget: Additional CSS class applied to each filter cell (v2.18.0). Example
Boolean false Filter widget: If true, queries will search child row content by column (v2.22.0). Example
Boolean false Filter widget: If there are child rows in the table (rows with class name from "cssChildRow" option) and this option is true and a match is found anywhere in the child row, then it will make that row visible. (Modified v2.1).
Boolean true Filter widget: include all sibling rows of the matching child row (v2.23.4). Example
Boolean true Filter widget: If true, allows using "#:{query}" in anyMatch searches (v2.20.0).
Boolean true Filter widget: If true, a filter will be added to the top of each table column (v2.4).
String or Array "" Filter widget: Additional CSS class applied to each filter (v2.15). Example
String "data-value" Filter widget: This option contains the name of the data-attribute which contains the default (starting) filter value (v2.10.8). Example
Object { } Filter widget: Add a default filter type to a column (v2.17.8). Example
Object { } Filter widget: Additional CSS class applied to each filter (v2.17.8). Exclude a filter type(s) for a column.
String "" Filter widget: jQuery selector string of inputs, outside of the table, to be used for searching table content (v2.15). Example
String "filtered" Filter widget: This is the class name applied to all rows that do not match the filter (hidden rows); used by pager plugin (v2.10).
String 'Filter "{{label}}" column by...' This option contains the ARIA-label value to be added to the filter input or select (v2.29.4). Example
Object null Filter widget: This option allows you to add custom controls within the filter widget row (v2.7.7; v2.17.0).
1 2
Object null Filter widget: Customize the filter widget by adding a select dropdown with content, custom options or custom filter functions (v2.3.6; v2.17.0). Example
Boolean true Filter widget: Set this option to false to always show the filter row; by default, the filter row is completely hidden when no rows exist within the tbody (v2.15).
Boolean, or Function false Filter widget: Set this option to true to hide the filter row initially. The row is revealed by hovering over the visible portion of the filter row or by giving any filter input/select focus (tab key) (v2.4; v2.26.6). Example
Boolean true Filter widget: Set this option to false to make the column content search case-sensitive, so typing in "a" will not find "Albert". (v2.3.4) Example
Boolean, Number or Object true Filter widget: If true, a search of the column content will occur as the user types, with the delay set in the filter_searchDelay option (v2.9; v2.27.3).
Object { 'input': 'exact', 'select': 'exact' } Filter widget: This option sets the global setting that applied to either input or select filters (v2.25.5) Example
String "filter-onlyAvail" Filter widget: If a header contains a select dropdown and this class name, only the available (visible) options in the column will show (v2.10.1; v2.17.6). Example
object { search : '', select : '' } Filter widget: Set global filter input placeholder text for search inputs and selects (v2.16). Example
String, jQuery object null Filter widget: jQuery selector string of an element used to reset the filters (v2.4; v2.16). Example
Boolean true Filter widget: when true, normalize pressing escape to clear filter input across browsers (v2.25.2).
Boolean false Filter widget: If the storage utility is available (included with jquery.tablesorter.widgets.js file, the last applied filter is saved to storage (v2.14). Example
Numeric 300 Filter widget: Set this option to the number of milliseconds to delay the search. (v2.3.4).
Boolean true Filter widget: Set this option to allow searching through already filtered rows (in special conditions); this will speed up searching in large tables (v2.17.4). Example
Function null Filter widget: Include a function to return an array of values to be added to the column filter select (v2.16.0; v2.28.12). 1 2
String '|' Filter widget: Set this option to be any separator (v2.17.6) that is to be used within the filter_selectSource returned array.
Boolean false Filter widget: Set this option to true if filtering is performed on the server-side (v2.5.3).
Boolean false Filter widget: Set this option to true to use the filter to find text from the start of the column, so typing in "a" will find "albert" but not "frank", both have a's. (v2.1). Example
Boolean false Filter widget: If true, ALL filter searches will only use parsed data (v2.4).
Boolean true Resizable widget: If this option is set to false, resized column widths will not be saved. Previous saved values will be restored on page reload (v2.4). Example
Boolean false Resizable widget: If this option is set to true, a resizing anchor will be included in the last column of the table (v2.8.3). Example
Boolean true Resizable widget: If this option is set to true, the resizable handle will extend into the table footer (v2.28.8).
Boolean false Resizable widget: When true, the last column will be targeted for resizing (v2.21.3).
Boolean false Resizable widget: Set this option to throttle the resizable events (v2.17.4).
Array [] Resizable widget: Set this option to the starting & reset header widths (v2.15.12). Example
Boolean true SaveSort widget: If this option is set to false, new sorts will not be saved. Any previous saved sort will be restored on page reload (v2.4). Example
String "" Sticky Headers widget: This additional CSS class applied to the sticky header row (v2.11). Example
Boolean true Sticky Headers widget: If true, sticky table headers will resize automatically when content is added to or removed from the table headers (v2.10).
String, jQuery Object null Sticky Headers widget: jQuery selector or object to physically attach the sticky headers (v2.27.0).
String, jQuery Object null Sticky Headers widget: points to the table wrapper to stick the headers to while scrolling. Use this option to point to their needs (v2.14.4). Example
String "-sticky" Sticky Headers widget: If the table has an ID defined, the suffix from this option will be added to the ID in the cloned sticky table (v2.9).
Boolean true Sticky Headers widget: Scroll table top into view after filtering (v2.16.2).
Boolean true Sticky Headers widget: If this option is false and a caption exists, it will not be included in the sticky header (v2.10.8). Example
Multiple 0 Sticky Headers widget: Set the sticky header offset from the top as a Number or jQuery selector string or object (v2.10).
String, jQuery Object null Sticky Headers widget: points to the element in which to monitor for horizontal scrolling (v2.18.0). Example
String, jQuery Object null Sticky Headers widget: points to the element in which to monitor for vertical scrolling (v2.18.0). Example
Numeric 2 Sticky Headers widget: The zIndex added to the stickyHeaders. This option allows the user to adjust the value to their needs (v2.11).
String "" Storage widget: This option allows setting an alternate table url so that tables on multiple pages will have their settings grouped together
String "" Storage widget: Set a table (data) attribute to use to obtain a table id, which allows grouping multiple tables on one page together - they share a common saved setting.
String "" Storage widget: Set a table (data) attribute to use to obtain a table url, which allows grouping tables across multiple pages together - they share a common saved setting.
String "" Storage widget: Set this option to the first letter of the desired storage type (v2.28.8).
String "" Storage widget: This option allows setting an alternate table id so multiple tables on a page have the settings grouped together
Boolean false Storage widget: This option was deprecated in v2.28.8. Example
Array [ "even", "odd" ] Zebra widget: When the zebra striping widget is initialized, it automatically applied the default class names of "even" and "odd". (Modified v2.1). Example
Pager
Function null This callback allows you to customize the error message displayed in the thead (v2.23.0; v2.23.1).
Object { dataType: 'json' } This option contains the ajax settings for the pager interaction with your database (v2.10). Example
Function function (data) { return data; } This function is required to return the ajax data obtained from your server into a useable format for tablesorter to apply to the table (v2.1, Updated v2.30.8). Example
String null Set this option to include a url template to use so that the pager plugin can interact with your database (v2.1; v2.9). Example
Object null Target your one or more pager markup blocks by setting this option with a jQuery selector. Example
Boolean false If true, child rows will be counted towards the pager set size (v2.13).
String "disabled" This option contains the class name that is applied to disabled pager controls.
String "tablesorter-errorRow" This option contains the class name that is applied to the error information row that is added inside the pager with any ajax exceptions.
String ".first" This option contains a jQuery selector string pointing to the go to first page arrow. See container for full HTML. Example
String ".gotoPage" This option contains a jQuery selector string pointing to the page select dropdown. See container for full HTML (v2.4; v2.17.3) Example
String ".last" This option contains a jQuery selector string pointing to the go to last page arrow. See container for full HTML. Example
String ".next" This option contains a jQuery selector string pointing to the go to next page arrow. See container for full HTML. Example
String ".pagedisplay" This option contains a jQuery selector string pointing to the output element (v2.0.9) Example
String ".pagesize" This option contains a jQuery selector string pointing to the page size selector. See container for full HTML. Example
String ".prev" This option contains a jQuery selector string pointing to the go to previous page arrow. See container for full HTML. Example
Function function(table, url) { return url; } This callback function allows you to modify the processed URL as desired (v2.8.1). Example
Boolean false Maintain the height of the table even when fewer than the set number of records is shown (v2.1; updated 2.7.1). Example
Object undefined When processAjaxOnInit is set to false, set this option to contain the total number of rows and filtered rows to prevent an initial ajax call (v2.25.4).
String "{startRow} to {endRow} of {totalRows} rows" This option allows you to format the output display which can show the current page, total pages, filtered pages, current start and end rows, total rows and filtered rows (v2.0.9; v2.28.4). 1 2 3 4
Numeric 0 Set the starting page of the pager (zero-based index). Example
Numeric, Boolean 0 Reset pager to this page after filtering; set to desired page number (zero-based index), or false to not change page at filter start (v2.16).
Boolean true Set this option to false if your table data is preloaded into the table, but you are still using ajax (v2.14.5).
Boolean false If true, rows are removed from the table to speed up the sort of large tables (v2.0.21). Example
Boolean true Saves the current pager page size and number. This option requires the $.tablesorter.storage script in the jquery.tablesorter.widgets.js file (v2.11). Example
Numeric 10 Set initial number of visible rows. This value is changed by the dropdown selector targeted by the cssPageSize option. Example
String "tablesorter-pager" Saves tablesorter paging to custom key if defined. Key parameter name used by the $.tablesorter.storage function. Useful if you have multiple tables defined (v2.15) Example
Boolean true If true, the addon hides the left pager arrow on the first page and right pager arrow on the last page. Example
Removed Options
Boolean false Filter: This option was removed in v2.15... sorry for the sudden notice.
Numeric 0 Pager: This option was removed!
Boolean true Pager: This option was removed!
String "/" Pager: This option was removed! Use the output option to allow for more control over the formatting.
String "jui" UiTheme: This option was removed in v2.19.0! It has been replaced by theme. Example

Methods

tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
TIP! Click on the link in the method column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
Method
Description
Link
Use this method to add table rows (v2.0.16; v2.23.0). Example
Adds all of the cached table rows back into the table (v2.23.0).
Apply the selected widget to the table, but the widget will not continue to be applied after each sort. See the example, it's easier than describing it (v2.25.4). Example
Apply the set widgets to the table (v2.29.0). Example
Use this method to remove tablesorter from the table (v2.3.2; v2.16).
Refresh the currently applied widgets. Depending on the options, it will completely remove all widgets, then re-initialize the current widgets or just remove all non-current widgets (v2.4; v2.19.0). Example
Remove the named widget from the table (v2.25.0). Example
Use this method reset the table to it's original settings. (v2.17.0).
Use this method to initialize a sort while targeting a specific column header (v2.9).
Use this method to sort an initialized table in the desired order (v2.23.0) Example
Use this method to set the table into an unsorted state (v2.4.7; v2.23.0). Example
/ Update the tbody's stored data (update & updateRows do exactly the same thing; v2.23.0) Example
Update a column of cells (thead and tbody) (v2.8; v2.23.0). Example
Update the parsers, only if not defined, then update the internal cache (v2.15.4; v2.27.0). Example
Update a table cell in the tablesorter data (v2.23.0). Example
Refresh table headers only (v2.23.0).
Widget Methods
filter: Trigger the filter widget to reset the sort & reset the search criteria (v2.28.7).
filter: Trigger the filter widget to reset the search criteria (v2.7.7). Example
filter: Make the filter widget reset any saved searches (v2.25.6). Example
Trigger the saveSort widget to clear any saved sorts for that specific table (v2.7.11).
Pager Methods
Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16; v2.23.0). Example
This method will put the pager into a disabled state (v2.0.21.2; v2.23.0). Example
This method will re-enable the pager, but only from the disabled state (v2.0.21.2; v2.23.0). Example
Trigger the pager to change the current page & size (v2.19.0; ; v2.24.0).
Force the pager to update the table with the current settings (v2.19.0).
Trigger the pager to change the current page (v2.7.7).
Trigger the pager to change the page size (v2.7.4; v2.24.0).

Events

tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
TIP! Click on the link in the event column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
Event
Description
Link
This event fires after tablesorter has completed executing the refreshWidget method (v2.19.0)
This event fires immediately before tablesorter begins resorting the table.
This event fires when tablesorter has completed resorting the table. Example
This event fires immediately after the tablesorter header has been clicked, initializing a resort. Example
This event fires when tablesorter has completed initialization. (v2.2).
This event fires after tablesorter has complete applying all widgets and is ready for its next action (v2.24.0).
This event fires after tablesorter has completed updating (v2.3.9).
Widget Events
Event triggered when the filter widget has finished processing the search (v2.4). Example
Event triggered when the filter widget has finished initializing (v2.4). Example
Event triggered when the filter widget has started processing the search (v2.4). Example
Event triggered when the stickyHeader widget has finished initializing (v2.10.4).
Event triggered after any widget has finished being removed (v2.29.0). Example
Pager Events
This event fires when the pager plugin begins to change to the selected page (v2.4.4). Example
This event fires after all pager controls have been bound and set up but before the pager formats the table or loads any ajax data (v2.4.4).
This event fires when the pager plugin begins to render the table on the currently selected page. (v2.0.7). Example
This event fires when the pager plugin has completed initialization (v2.18.1), and its render of the table on the currently selected page. (v2.0.7). Example
This event fires when the pager plugin has completed initialization (v2.4.4). Example

Tablesorter API

tablesorter has some useful internal variables & functions available through the API which can be used in custom coding, parsers and/or widgets.

Variables

TIP! Click on the link in the variable column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
Variable
Type
Description
Link
Object This object contains all of the default settings shown in the configuration section.
Object This variable contains all instance methods of the config object. Added using addInstanceMethods function before table initialization (v2.21.0).
Object This object contains the phrases (in English by default) added to the aria-label on each header column (v2.24.4). 1 2
Array This is an array of all parser objects added using the addParser function.
$.tablesorter.themes Object This is an object containing a list of specific class names to be applied to table elements. Please see the widget uitheme option for more details.
Array This is an array of all widget objects added using the addWidget function.
Access the table configuration variables (config) using any of these methods:
Array Internally stored Array of headers that represent each column (v2.21.0)
jQuery Object Internal list of all table header cells (v2.8)
jQuery Object Internally stored jQuery object of the table (v2.7.1)
jQuery Object Internally stored jQuery object of table non-info block tbodies (v2.7.1)
Object Internal list of table contents (v2.0.18; v2.20.0 )
Numeric Internal count of the number of table columns in the header (v2.12)
Array Internal list of each header's starting HTML (as text) (v2.8)
Array Internal list of each header element as selected using jQuery selectors in the selectorHeaders option.
Array Internal list of all of the table's currently set parsers (objects copied from $.tablesorter.parsers). Here is a complete list of default parsers: (modified v2.18.0) 1 2 3 4
Object Internally stored object of column specific sort variables (v2.24.0; Updated v2.30.7)
DOM element Internally stored DOM table element (v2.17.5)
Numeric This variable contains the total number of rows within the table, not including rows within info-only tbodies (v2.17.4; v2.17.5)
Boolean Boolean value indicating that tablesorter has been initialized on a table
Access the widgetOptions (wo) using any of these methods:
jQuery Object Only available when the filter widget is active. This variable contains all table cells within the filter row.
Numeric Only available when the filter widget is active. This variable contains the current number of filtered rows (v2.17.4; v2.17.5)
jQuery Object Only available when the stickyHeaders widget (not the css3 version) is active.
jQuery Object Only available when the filter widget is active. This variable contains all external search inputs with data-column="all", bound using the bindSearch function.
jQuery Object Only available when the filter widget is active. This variable contains all external search inputs bound using the bindSearch function.
wo.filter_initialized Boolean Only available when the filter widget is active. This variable is true once the filter widget has initialized; it is undefined otherwise.
Access the pager options (p) using any of these methods:
jQuery Object Contains a jQuery object pointing to a pager block(s).
jQuery Object Contains a jQuery object pointing to an empty select within the pager block(s).
jQuery Object Contains a jQuery object pointing to a select with the desired page size settings already in place.
Array Contains an array of zero-based row indexes of rows that currently displayed within the table.
Numeric Contains a one-based index of the last row visible in the pager.
Numeric Contains the page count, determined by the page size setting, after the table is filtered. It equals the totalPages if no filters are applied.
Numeric Contains the number of rows accessible by the pager after the table is filtered. It equals the totalRows if no filters are applied.
Numeric Contains a zero-based index of the current page visible in the pager.
Numeric Contains the currently selected page size.
Numeric Contains a one-based index of the first row visible in the pager.
Numeric Contains the total page count as determined by the page size setting.
Numeric Contains the total number of rows within the table
Removed Variables
jQuery Object Internal list of all extra table header cells (v2.16.2; removed v2.21.3)
jQuery Object Internal list of all extra (cloned) table elements (v2.19.0; removed v2.21.3)

Functions

TIP! Click on the link in the function column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
Function
Description
Core Functions
This function allows to add custom methods for config object (v2.21.0).
This function allows the adding of custom parser scripts to the tablesorter core.
This function allows the adding of custom widget scripts to the tablesorter core (v2.19.0).
This function applys (refreshes) all currently selected widgets on a table (v2.16.0; v2.19.0).
This function adds header event listeners to the targeted cells (v2.8; v2.16.2).
This function empties ALL of the table tbodies (v2.17.2).
Adds the correct data-column indexing to all rows passed to this function (v2.16; v2.25.0).
This function completely removes tablesorter, including all widgets, associated data & event handlers from the table (v2.3.2).
This function adds a colgroup element to the table when widthFixed is true.
This function converts a number string into a number type.
This function returns the column data from an object based on a column index or classname/id (v2.21.1).
This utility function returns the entire column text (raw and parsed) as well as other data (v2.21.4; v2.24.0).
This functions gets the sorter, string, empty, etc options for each column from jQuery data, metadata, header option or header class name ("sorter-false") (v2.1.16).
This function returns the named parser object.
This function returns the named widget object.
This function allows the checking to see if a widget is installed (v2.17.4).
This function determines if a string contains a number after removing commas, periods, quotes and spaces.
This function adds the processing (indeterminant loading icon) to specific or all header cells while processing table elements (v2.4).
This function returns a zero-based index value of the position of the value within the array, otherwise it returns -1 (Modified v2.15.6).
This function detaches the targeted tbody from the DOM to allow faster manipulation of the tbody contents (v2.4).
This function removes, then reapplies all currently selected widgets on a table (v2.4; v2.19.0).
This function removes selected widgets (v2.19.0).
This function replaces basic accented characters to better sorting & filtering of table contents (v2.2).
This function restores the table headers cells with their original content (v2.8).
This function allows adding/removing a row to the thead, to display any errors (v2.15; v2.23.1).
This function sorts the a & b parameter using a natural sort (v2.12; v2.28.13).
This function sorts the a & b parameter using a basic sort (renamed v2.12).
Widget Functions
Added a resize event to the table headers - used by the stickyHeaders widget, but this is a public function available to any widget (v2.10).
This filter widget function allows binding external search filters to the table (v2.13.3; v2.15).
This filter widget function allows the updating or replacing of filter select options from an external source. (v2.17.5):
This filter widget function allows getting an array of the currently applied filters (v2.9; v2.15)
This filter widget function returns all the cached values of the set table column (v2.16.0):
This filter widget function returns all the cached values of the set table column (v2.16.0):
This filter widget function returns an array of sorted column data will duplicates removed (v2.23.4).
This resizable widget function allows resetting column width changes and clearing out the saved set widths (v2.4; v2.10.1)
This filter widget function allows setting of the filters; include a true boolean to actually apply the search (v2.9; v2.24.3):
This function allows saving specific table data (especially widgets) to local storage (cookie fallback for no browser support) (v2.1)

Download

File Downloads Required: Optional / Add-Ons: Themes:

Theme zip files have been removed. There are now numerous themes available which can be seen here.

Browser Compatibility

tablesorter has been tested successfully in the following browsers with Javascript enabled:

jQuery Browser Compatibility

Support

First, please review the FAQ page to see if it will help you resolve the problem.

If you are having a problem with the plugin or you want to submit a feature request, please submit an issue.

Support is also available from stackoverflow.

If you would like to contribute, fork a copy on github.

Some basic unit testing has been added (v2.6). If you would like to add more or report a problem, please use the appropriate link above.

For questions about jQuery, try irc, stackoverflow, or the jQuery forums.

Credits

Written by Christian Bach.

Documentation written by Brian Ghidinelli, based on Mike Alsup's great documention.

Additional & Missing documentation, alphanumeric sort, numerous widgets, unit testing and other changes added by Mottie.

Thanks to all that have contributed code, comments, feedback and everything else. A special thanks goes out to:

John Resig for the fantastic jQuery