Original Author: Christian Bach
Maintainer of this fork: Rob Garrison (Mottie)
Version: 2.1+ (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.
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).

If true, the cache will contain duplicated cell contents for every column the colspan includes. This makes it easier to sort & filter columns because a cell spanning all columns will only work with one parser.

In v2.25.8, the contents of cells that are spanned will be set to an empty string only if the textExtraction setting is left as a string. If a function is added, it will be used to attempt to extract other content from the spanned cell (see demo for an example).

// this row: <tr><td colspan="3">foo</td><td>bar</td></tr> results in this row cache:
[ 'foo', 'foo', 'foo', 'bar' ] // if duplicateSpan = true
[ 'foo', '',    '',    'bar' ] // if duplicateSpan = false (no textExtraction function)
*NOTE*
  • Cells in the tbody with a rowspan are not yet supported and will not sort or filter as you would expect.
  • Having these values in the cache does not automatically guarantee that all widgets will work as expected with colspans in the tbody (e.g. scroller widget with fixed columns)
Example
String "" Additional CSS class applied to style the header with a ascending sort (v2.11).

Changed to empty string ("") in v2.11, as the "tablesorter-headerAsc" class will always be added to a header cell with an ascending sort; this option now contains any additional class names to add.

Example from the blue theme:

.tablesorter-blue .tablesorter-headerAsc {
  background-color: #9fbfdf;
  background-image: url(black-asc.gif);
}
Default changed v2.5 to "tablesorter-headerAsc". Default changed v2.1.7 to "tablesorter-headerSortUp". Original default: "headerSortUp"
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
This is an entirely new row, but attached to the row above while sorting
cssChildRow Example HTML:
<table width="100%" border="1">
  <thead>
    <tr>
      <th>Item #</th>
      <th>Name</th>
      <th>Available</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>12345</td>
      <td>Toy Car</td>
      <td>5</td>
    </tr>
    <tr class="tablesorter-childRow"> <!-- this row will remain attached to the above row, and not sort separately -->
      <td colspan="3">
        It's a toy car!
      </td>
    </tr>
    <tr>
      <td>23456</td>
      <td>Toy Plane</td>
      <td>2</td>
    </tr>
    <tr class="tablesorter-childRow"> <!-- this row will remain attached to the above row, and not sort separately -->
      <td colspan="3">
        It's a toy plane!
      </td>
    </tr>
    <tr class="tablesorter-childRow"> <!-- this row will remain attached to the above two rows, and not sort separately -->
      <td colspan="3">
        and it flies!
      </td>
    </tr>
  </tbody>
</table>
String "" Additional CSS class applied to style the header with a descending sort (v2.11).

Changed to empty string in v2.11, as the "tablesorter-headerDesc" class will always be added to a header cell with a descending sort; this option now contains any additional class names to add.

Example from the blue theme:

.tablesorter-blue .tablesorter-headerDesc {
  background-color: #8cb3d9;
  background-image: url(black-desc.gif);
}
Default changed v2.5 to "tablesorter-headerDesc". Default changed v2.1.7 to "tablesorter-headerSortDown". Original default: "headerSortDown"
String "" Additional CSS class applied to style the headers (v2.11).

Changed to empty string in v2.11, as the "tablesorter-header" class will always be added to the table headers; this option now contains any additional class names to add.

Example from the blue theme:

.tablesorter-blue .tablesorter-header {
  background-color: #99bfe6;
  background-repeat: no-repeat;
  background-position: center right;
  padding: 4px 20px 4px 4px;
  white-space: normal;
  cursor: pointer;
}
Default changed v2.1.7 to "tablesorter-header". Original default: "header"
String "" Additional CSS class applied to style the header row (v2.11).

Changed to empty string in v2.11, as the "tablesorter-headerRow" class will always be added to a table header row; this option now contains any additional class names to add.

This CSS style was added in v2.4, prior to that the row would get the same class as the header cells. This class was added to make it easier to determine what element was being targeted in the plugin.

String "tablesorter-icon" The CSS style used to style the header cell icon (modified v2.7; v2.21.1).

In v2.21.1, adding multiple class names to this option is now properly supported.

As of v2.7, the icon will only be added to the header if both the cssIcon option is set AND the headerTemplate option includes the icon tag ({icon}).

In v2.4, an <i> element, with this class name, is automatically appended to the header cells. To prevent the plugin from adding an <i> element to the headers, set the cssIcon option to an empty string.
String "" The CSS style added to the header cell icon when the column has an ascending sort (v2.18.3).

This class is only applied when the headerTemplate option includes a {icon} tag or an HTML element with the class name from the cssIcon option.
String "" The CSS style used to style the header cell icon when the column has a descending sort (v2.18.3)

This class is only applied when the headerTemplate option includes a {icon} tag or an HTML element with the class name from the cssIcon option.
String "" The CSS style used to style the header cell icon when the column does not have a sort applied (v2.18.3)

This class is only applied when the headerTemplate option includes a {icon} tag or an HTML element with the class name from the cssIcon option.
String "" Additional CSS class applied to style the header when no sort is applied (v2.15).

A "tablesorter-headerUnSorted" class will always be added to an unsorted header cell; this option contains any additional class names to add. Currently, no themes use this class name.
String "" Additional CSS class applied to style the header cell while it is being sorted or filtered (v2.4; v2.11).

Changed to empty string in v2.11, as the "tablesorter-processing" class will always be added to a table cells during processing; this option now contains any additional class names to add.

This class name is added to the header cell that is currently being sorted or filted. To prevent this class name from being added, set the showProcessing option to false.

String "tablesorter-infoOnly" All tbodies with this class name will not have its contents sorted. (v2.2).

With the addition of multiple tbody sorting in v2.2, you can now insert a non-sorting tbody within the table by adding this class to the tbody.
<tbody class="tablesorter-infoOnly">
  <tr>
    <th>The contents of this tbody</th>
  </tr>
  <tr>
    <td>will not be sorted</td>
  </tr>
</tbody>
As an example, I've split up this options table into three (3) tbodies. The first contains the active options, the second is the info block with a row that only contains the text "Deprecated Options", and the last tbody contains the deprecated options. Sort the table to see how each tbody sorts separately.

NOTE! The pager plugin will only be applied to the first tbody, as always. I may work on modifying this behavior in the future, if I can figure out the best implementation.

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 "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).

Header rows with this class name will not be added into the table.config.$headers variable. Meaning, any cells in the row will have sorting disabled, and any form element interaction within these cells will also be ignored by tablesorter.

This class name should be added to header rows that contain custom HTML, like for the pager controls, custom filter row or table toolbar.
Example
String "mmddyyyy" Set the date format. Here are the available options. (Modified v2.0.23).
  • "mmddyyyy" (default)
  • "ddmmyyyy"
  • "yyyymmdd"
In previous versions, this option was set as "us", "uk" or "dd/mm/yy". This option was modified to better fit needed date formats. It will only work with four digit years!

The sorter should be set to "shortDate" and the date format can be set in the "dateFormat" option or set for a specific columns within the "headers" option. See the demo page to see it working.
$(function(){
  $("table").tablesorter({

    dateFormat : "mmddyyyy", // default date format

    // or to change the format for specific columns,
    // add the dateFormat to the headers option:
    headers: {
      0: { sorter: "shortDate" }, // "shortDate" with the default dateFormat above
      1: { sorter: "shortDate", dateFormat: "ddmmyyyy" }, // day first format
      2: { sorter: "shortDate", dateFormat: "yyyymmdd" }  // year first format
    }

  });
});
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (Modified v2.3.1):
  • jQuery data data-dateFormat="mmddyyyy".
  • metadata class="{ dateFormat: 'mmddyyyy'}". This requires the metadata plugin.
  • headers option headers : { 0 : { dateFormat : 'mmddyyyy' } }.
  • header class name class="dateFormat-mmddyyyy".
  • Overall dateFormat option.
Example
debug Boolean false Boolean flag indicating if tablesorter should display debuging information useful for development. 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
String "bottom" Option indicating how tablesorter should deal with empty table cells. (Modified v2.1.16, v2.16.2).
  • bottom - sort empty table cells to the bottom.
  • top - sort empty table cells to the top.
  • none or zero - sort empty table cells as if the cell has the value equal to zero.
  • emptyMax - sort empty table cells as having a value greater than the max (more positive) value (v2.16.2).
  • emptyMin - sort empty table cells as having a value greater than the min (more negative) value (v2.16.2).
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
  • jQuery data data-empty="top".
  • metadata class="{ empty: 'top'}". This requires the metadata plugin.
  • headers option headers : { 0 : { empty : 'top' } }.
  • header class name class="empty-top".
  • Overall emptyTo option.
emptyToBottom option was added in v2.1.11, then replaced by the emptyTo option in v2.1.16.
Example
Object null An object of instructions for per-"header cell" controls in the format: headers: { 0: { option: setting }, ... } (v2.17.1)

For example, to disable sorting on the first two columns of a table: headers: { 0: { sorter: false}, 1: {sorter: false} }.

The plugin attempts to detect the type of data that is contained in a column, but if it can't figure it out then it defaults to alphanumeric. You can easily override this by setting the header argument (or column parser). See the full list of default parsers here or write your own.
$(function(){
  $("table").tablesorter({
    headers: {

      // See example - Disable first header cell; parser false skips extracting content
      0: { sorter: false, parser: false },

      // WARNING! The "ipAddress" parser was MOVED into the "parser-network.js" file
      // in v2.18.0
      1: { sorter: "ipAddress" },

      // See example 2: Sort column numerically & treat any text as if its value is:
      2: { sorter: "digit", empty:  "top" }, // zero; sort empty cells to the top
      3: { sorter: "digit", string: "max" }, // maximum positive value
      4: { sorter: "digit", string: "min" }, // maximum negative value

      // Sort the sixth column by date & set the format
      5: { sorter: "shortDate", dateFormat: "yyyymmdd" }, // year first format

      // See example 3: lock the sort order
      // this option will not work if added as metadata
      6: { lockedOrder: "asc" },

      // See Example 4: Initial sort order direction of 8th header cell
      7: { sortInitialOrder: "desc" },

      // Set filter widget options for this column
      // See the "Applying the filter widget" demo
      8: { filter: false },    // disable filter widget for this column
      9: { filter: "parsed" }, // use parsed data for this column in the filter search

      // Set resizable widget options for this column
      10: { resizable: false } // prevent resizing of the 11th column

    }
  });
});
Please note that the headers index values corresponds to the table header cells index (zero-based) and not the actual columns. For example, given the following table thead markup, the header-index counts the header th cells and does not actually match the data-column index when extra rows and/or colspan or rowspan are included in any of the header cells:
<thead>
	<tr>
		<th colspan="4" data-column="0">header-index 0</th>
	</tr>
	<tr>
		<th data-column="0">header-index 1</th>
		<th data-column="1">header-index 2</th>
		<th data-column="2">header-index 3</th>
		<th data-column="3">header-index 4</th>
	</tr>
	<tr>
		<th colspan="2" data-column="0">header-index 5</th>
		<th colspan="2" data-column="2">header-index 6</th>
	</tr>
</thead>
So, in the above example, to disable the sort of the second table column (data-column index of 1), the header cell of index 2 needs to be set as follows: 2 : { sorter : false }.

In v2.17.0, you can reference the column(s) using a class name, id or column index.
headers : {
    '.first-name' : { sorter: 'text' },
    '.disabled'   : { sorter: false }
}
Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.
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).

In v2.17.8, if this option is set to an empty string (''), an inner div will no longer be wrapped around the header content.

This template string has two modifying tags: {content} and {icon}.
{content} will be replaced by the current header HTML content.
{icon} will be replaced by <i class="tablesorter-icon"></i>, but only if a class name is defined in the cssIcon option.

This template string may also contain HTML, e.g ('<em>{content}</em> {icon}')

After the template string is built, the onRenderTemplate function is called to allow further manipulation. Please read more about this onRenderTemplate function and/or check out the example (link to the right).
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).
$(function(){

  // bind to tablesorter-initialized event BEFORE initializing tablesorter*
  $("table")
    .bind("tablesorter-initialized",function(e, table) {
      // do something after tablesorter has initialized
    });

  // initialize the tablesorter plugin
  $("table").tablesorter({
    // this is equivalent to the above bind method
    initialized : function(table){
      // do something after tablesorter has initialized
    }
  });

});
* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs.
Boolean true Apply widgets after table initializes (v2.3.5).
When true, all widgets set by the widgets option will apply after tablesorter has initialized, this is the normal behavior.

If false, the each widget set by the widgets option will be initialized, meaning the "init" function is run, but the format function will not be run. This is useful when running the pager plugin after the table is set up. The pager plugin will initialize, then apply all set widgets.

Why you ask? Well, lets say you have a table with 1000 rows that will have the pager plugin applied to it. Before this option, the table would finish its setup, all widgets would be applied to the 1000 rows, pager plugin initializes and reapplies the widgets on the say 20 rows showing; making the widget application to 100 rows unnecessary and a waste of time. So, when this option is false, widgets will only be applied to the table after the pager is set up.
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)

By default, this option is set to 'widget-{name}'. So if the table has a class name of widget-zebra the zebra widget will be automatically added to the config.widgets option and applied to the table.

Some widget ID's with special characters may not be detected; ID's with letters, numbers, underscores and/or dashes will be correctly detected.

The template string *must* contain the {name} tag.
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).

In versions 2.0.6+, all TH text is wrapped in a div with a class name of "tablesorter-inner" by default. In the example below, the header cell (TH) div is given a class name (source).
Function parameters:
  • index - zero-based index of the current table header cell; this value is not indicative of the column index, as it is simply a count of header cells. So it will be effected by rowspan, colspan and multiple rows in the header.
  • config - The current table.config.
  • $table - This value is the current table jQuery object. If this function is being applied to cloned headers, as is does in the stickyHeaders widget, then this value will contain the sticky header clone added after the current table, and not the main table (v2.18.0).
$(function(){
  $("table").tablesorter({
    headerTemplate: '{content}',
    onRenderHeader: function (index, config, $table){
      $(this).find('div').addClass('roundedCorners');
    }
  });
});
and you'll end up with this HTML (only the thead is shown)
<thead>
  <tr>
    <th class="tablesorter-header"><div class="tablesorter-header-inner roundedCorners">Column 1</div></th>
    <th class="tablesorter-header"><div class="tablesorter-header-inner roundedCorners">Column 2</div></th>
  </tr>
</thead>
* Note: this function adds additional rendering time to the table if any DOM manipulation is done. Because this time will be on top of the processing time already added by the template.
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).

The onRenderTemplate function receives a column index and template string parameters. The template string, from the headerTemplate option, will already have the {icon} and {content} tags replaced; it's just a string of formatted HTML. When done manipulating this string, return it. Here is an example:
$(function(){
  $("table").tablesorter({
    headerTemplate: '{icon}{content}',
    onRenderTemplate: function (index, template){
      return '<em>' + (index + 1) + ':</em> ' + template;
    }
  });
});
The template parameter can be manipulated as a string, or if you prefer, turn it into a jQuery object (var $t = $(template)) to find and replace content as desired. Just make sure you return a string (return $t.html())

From the example function above, you'll end up with something similar to this HTML (only the thead is shown)
<thead>
  <tr>
    <th class="tablesorter-header"><div class="tablesorter-header-inner"><em>1:</em> <i class="tablesorter-icon"></i>First Name</div></th>
    <th class="tablesorter-header"><div class="tablesorter-header-inner"><em>2:</em> <i class="tablesorter-icon"></i>Last Name</div></th>
  </tr>
</thead>
* Note: If the cssIcon option is an empty string, the {icon} tag will also become an empty string.
Example
String "> thead th, > thead td" jQuery selectors used to find cells in the header.

You can change this, but the table will still need the required thead and tbody before this plugin will work properly.
Added > to the selector in v2.3 to prevent targeting nested table headers. It was modified again in v2.4 to include td cells within the thead.
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).

It was necessary to add this option because some widgets add table rows for styling (see the writing custom widgets demo) and if a table update is triggered ($('table').trigger('update');) those added rows will automatically become incorporated into the table.
selectorSort String "th, td" jQuery selector of content within selectorHeaders that is clickable to trigger a sort (v2.4). Example
Boolean true When this option is true any applied sort on the table will be reapplied after an update method (v2.19.0).

Specifically, this option applies to the updateAll, update, addRows and updateCell methods and is checked after the method has completed updating the internal cache.

If false, the widgets will still be refreshed for all but the updateCell method - this behavior was added in v2.19.0.

Note when triggering one of the above methods, and passing a defined resort parameter, it will override this setting.
Note if a sort is not reapplied, problems with some widgets may occur, namely with the grouping widget.
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 null Use to add an additional forced sort that is prepended to sortList.

NOTE Only when the user interacts with the table will the sortForce and sortAppend settings be applied. During initialization, and while setting the sortList through the API, both the sortForce and sortAppend settings are ignored. This will allow you to have explicit control over the sorting.

For example, sortForce: [[0,0]] will sort the first column in ascending order. After the forced sort, the user selected column(s), but not during initialzation, the sorting order defined in the sortList will follow. And lastly, the sort defined in the sortAppend option will be applied. More explicitly:

There are three options to determine the sort order and this is the order of priority:
  1. sortForce forces the user to have this/these column(s) sorted first (null by default).
  2. SortList is the initial sort order of the columns.
  3. SortAppend is the default sort that is added to the end of the users sort selection (null by default; v2.24.0).
The value of these sort options is an array of arrays and can include one or more columns. The format is an array of instructions for per-column sorting and direction in the format: [[columnIndex, sortDirection], ... ] where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: [[0,0],[1,0]].
$(function(){
  $("table").tablesorter({
    sortForce  : [[0,0]],        // Always sort first column first
    sortList   : [[1,0], [2,0]], // initial sort columns (2nd and 3rd)
    sortAppend : [[3,0]]         // Always add this sort on the end (4th column)
  });
});
Example
Array null Use to add an initial sort to the table.

NOTE Only when the user interacts with the table will the sortForce and sortAppend settings be applied. During initialization, and while setting the sortList through the API, both the sortForce and sortAppend settings are ignored. This will allow you to have explicit control over the sorting.

The value contains an array of instructions for per-column sorting and direction in the format: [[columnIndex, sortDirection], ... ] where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: [[0,0],[1,0]]. Please see sortForce for more details on other sort order options.
$(function(){
  $("table").tablesorter({
    sortList : [[1,0], [2,0]] // initial sort columns (2nd and 3rd)
  });
});
This option can also be set using data-attributes (v2.3.1), jQuery data or metadata on the table:
** Note: data-sortlist data is not supported in jQuery versions older than 1.4.
jQuery data<table data-sortlist="[[0,0],[4,0]]"> **
Meta data<table class="tablesorter {sortlist: [[0,0],[4,0]]}">
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).

NOTE Only when the user interacts with the table will the sortForce and sortAppend settings be applied. During initialization, and while setting the sortList through the API, both the sortForce and sortAppend settings are ignored. This will allow you to have explicit control over the sorting.

For example, can be used to sort people alphabetically after some other user-selected sort that results in rows with the same value like dates or money due. It can help prevent data from appearing as though it has a random secondary sort.
$(function(){
  $("table").tablesorter({
    sortAppend : [[1,0], [2,0]] // always append sorting of 2nd and 3rd column
  });
});
The value contains an array of instructions for per-column sorting and direction in the format: [[columnIndex, sortDirection], ... ] where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: [[0,0],[1,0]]. Please see sortForce for more details on other sort order options.

In v2.24.0, the sortAppend option now accepts an object containing column indexes.

Also, the sort direction can be set using "a" (ascending), "d" (descending), "n" (next), "s" (same) & "o" (opposite):

$(function(){
  $("table").tablesorter({
    sortAppend: {
      0 : [[ 1,'a' ]], // always apply ascending sort
      2 : [[ 3,'o' ]], // sort "o"pposite of column 2 direction
      4 : [[ 5,'s' ], [ 0,'s' ]]  // sort "s"ame as column 4 direction
    }
  });
});
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.

This order can also be set by desired column using the headers option (v2.0.8).

Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (modified v2.3.1):
  • jQuery data data-sortInitialOrder="asc".
  • metadata class="{ sortInitialOrder: 'asc'}". This requires the metadata plugin.
  • headers option headers : { 0 : { sortInitialOrder : 'asc' } }.
  • header class name class="sortInitialOrder-asc".
  • Overall sortInitialOrder option.
1 2
Boolean false Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. (Modified v2.2).
  • This option no longer switches the sort to use the String.localeCompare method.
  • When this option is true, the text parsed from table cells will convert accented characters to their equivalent to allow the alphanumeric sort to properly sort.
  • If false (default), any accented characters are treated as their value in the standard unicode order.
  • The following characters are replaced for both upper and lower case (information obtained from sugar.js sorting equivalents table):
    • áàâãä replaced with a
    • ç replaced with c
    • éèêë replaced with e
    • íìİîï replaced with i
    • óòôõöō replaced with o
    • úùûü replaced with u
    • ß replaced with S
  • Please see the example page for instrcutions on how to modify the above equivalency table.
  • If you would like to continue using the String.localeCompare method, then set the sortLocaleCompare option to false and use the new textSorter option as follows:
    $('table').tablesorter({
      textSorter: function(a,b) {
        return a.localeCompare(b);
      }
    });

NOTE! See the Language wiki page for language specific examples and how to extend the character equivalent tables seen in the sortLocaleCompare demo.

Boolean flag indicating whenever to use javascript String.localeCompare method or not.
This is only used when comparing text with international character strings. A sort using localeCompare will sort accented characters the same as their unaccented counterparts.
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).

Don't confuse this option with the sortReset method. This option only resets the column sort after a third click, while the method immediately resets the entire table sort.
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).

This isn't exactly a stable sort because the sort order maintains the original unsorted order when sorting the column in an ascending direction. When sorting the column in a descending order, the opposite of the original unsorted order is returned. If that doesn't make any sense, please refer to issue #419.
Example
String "shiftKey" The key used to select more than one column for multi-column sorting. Defaults to the Shift key.

The other options include "ctrlKey" or "altKey" (reference)

To make a multisort always active, use any of the other event objects that are always "truthy" like "type" or "bubbles". See issue #1200).
Example
String "max" A key word indicating how tablesorter should deal with text inside of numerically sorted columns. (v2.1.16).

String options was initially set in the header options only. Overall option added and values changed in version 2.1.16; setting the value to:
  • "max" will treat any text in that column as a value greater than the max (more positive) value. Renamed from "max+".
  • "min" will treat any text in that column as a value greater than the min (more negative) value. Renamed from "max-".
  • "top" will always sort the text to the top of the column.
  • "bottom" will always sort the text to the bottom of the column.
  • "none" or "zero" will treat the text as if it has a value of zero.
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
  • jQuery data data-string="top".
  • metadata class="{ string: 'top'}". This requires the metadata plugin.
  • headers option headers : { 0 : { string : 'top' } }.
  • header class name class="string-top".
  • Overall stringTo option.
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).

Changed to empty string in v2.11, as the "tablesorter" class will always be added to the table; this option now contains any additional class names to add.

This class was required in the default markup in version 2.0.5. But in version 2.0.6, it was added as an option.

Modify this option if you are not using the default css, or if you are using a completely custom stylesheet.
String "default" This option will add a theme css class name to the table "tablesorter-{theme}" for styling (v2.4; v2.18.0).

*NOTE* If creating a custom theme file, make sure to include a filter definition to hide filtered out rows:
.filtered { display: none; }

Note the .filtered class can be modified using the filter_filteredRow option.

When changing this theme option (the actual theme name is inside parentheses), make sure that the appropriate css theme file has also been loaded. Default theme files include: see all themes

uitheme widget

You will need to use the uitheme widget to extend the theme to apply css from jQuery UI, Bootstrap or other css libraries.

Modify a theme

If you want to modify the existing themes ("jui" and "bootstrap"), it can be done as follows:

Modify the class names by extending from the $.tablesorter.themes variable

Note there is no need to extend from the entire list of class names, just include the key:value pairs that are being changed:

// Extend a theme to modify any of the default class names
$.extend($.tablesorter.themes.jui, {
  // change default jQuery uitheme icons - find the full list of icons
  // here: http://jqueryui.com/themeroller/ (hover over them for their name)
  table        : 'ui-widget ui-widget-content ui-corner-all', // table classes
  caption      : 'ui-widget-content',
  // header class names
  header       : 'ui-widget-header ui-corner-all ui-state-default', // header classes
  sortNone     : '',
  sortAsc      : '',
  sortDesc     : '',
  active       : 'ui-state-active', // applied when column is sorted
  hover        : 'ui-state-hover',  // hover class
  // icon class names
  icons        : 'ui-icon', // icon class added to the <i> in the header
  iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // "caret" class renamed in jQuery v1.12.0
  iconSortAsc  : 'ui-icon-carat-1-n ui-icon-caret-1-n',
  iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s',
  // other
  filterRow    : '',
  footerRow    : '',
  footerCells  : '',
  even         : 'ui-widget-content', // even row zebra striping
  odd          : 'ui-state-default'   // odd row zebra striping
});

Custom theme

To add a new uitheme, define it as follows (replace "custom" with the name of your theme):
$.tablesorter.themes.custom = {
  table      : 'table',       // table classes
  header     : 'header',      // header classes
  footerRow  : '',
  footerCells: '',
  icons      : 'icon',        // icon class added to the <i> in the header
  sortNone   : 'sort-none',   // unsorted header
  sortAsc    : 'sort-asc',    // ascending sorted header
  sortDesc   : 'sort-desc',   // descending sorted header
  active     : 'sort-active', // applied when column is sorted
  hover      : 'hover',       // hover class
  filterRow  : 'filters',     // class added to the filter row
  even       : 'even',        // even row zebra striping
  odd        : 'odd'          // odd row zebra striping
}
Then use it by adding the name of your theme to the theme option:
$(function(){
  $("table").tablesorter({
    // set the new theme name from $.tablesorter.themes here
    theme   : 'custom',
    // add {icon} to template (if needed)
    headerTemplate: '{content}{icon}',
    // make sure to initialize uitheme widget
    widgets : ["uitheme"]
  });
});
Example
String "data-text" This data-attribute can be added to any tbody cell and can contains alternate cell text (v2.16.0).

This option contains the name of the data-attribute used by the textExtraction function. Add it to the cell(s) as follows:
<td data-text="1">First repository</td>
Note This option only works when the textExtraction option is set to "basic".

*NOTE* It is important to know that the filter widget is set to use extracted (parsed) content as a parsed value and the raw cell content as unparsed values; and most of the time the filter widget is searching unparsed content. But, when a data-attribute is used, both the parsed and raw cached data will contain the exact same content (ref)!

Multiple* "basic" Defines which method is used to extract data from a table cell for sorting (v2.19.0)

* Note This option accepts multiple types (String, Object or Function); see below for further details.

In v2.19.0, the code was further optimized. When set to "basic" (the default), the textExtraction code will check for data-attributes, otherwise, any other string value setting will skip the data-attribute value check; because of this change, there is a noticable lessening of initialization time in Internet Explorer.

In v2.17.0, the textExtraction column can also be referenced by using a jQuery selector (e.g. class name, id or column index) that points to a table header cell.
textExtraction : {
    // 'jQuery thead cell selector' : function ( new method )
    '.styled' : function(node, table, cellIndex) {
        return $(node).find('strong').text();
    },
    // columnIndex : function ( original method )
    2 : function(node, table, cellIndex) {
        return $(node).find('img').attr('title');
    }
}
Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

As of version 2.16.0,
  • The default text extraction method has been renamed and updated to get data from a data-attribute (set by the textAttribute option).
  • If you need to support older versions of IE, this may add a significant delay to the table initialization especially for large tables; in this case, set the textExtraction option to any name other than "basic".
  • Also, this option can now be set using a data-attribute named "data-text-extraction" on the table.
You can customize the text extraction by writing your own text extraction function "myTextExtraction" which you define like:
var myTextExtraction = function(node, table, cellIndex){
  // extract data from markup and return it
  // originally: return node.childNodes[0].childNodes[0].innerHTML;
  return $(node).find('selector').text();
}
$(function(){
  $("#myTable").tablesorter( { textExtraction: myTextExtraction } );
});
tablesorter will pass the current table cell object for you to parse and return. Thanks to Josh Nathanson for the examples; updated to a jQuery example by Rob G (Mottie).

Now if the text you are finding in the script above is say a number, then just include the headers sorter option to specify how to sort it. Also in this example, we will specify that the special textExtraction code is only needed for the second column (1 because we are using a zero-based index). All other columns will ignore this textExtraction function.

Added table and cellIndex variables to the textExtraction function in version 2.1.2 (this is not part of the original plugin).

$(function(){
  $("table").tablesorter({
    textExtraction: {
      1: function(node, table, cellIndex) {
           return $(node).find("span:last").text();
      }
    },
    headers: {
      1: { sorter : "digit" }
    }
  });
});
The built-in option is "basic" (modified v2.16.0) which is the equivalent of doing this inside of the textExtraction function: $(node).text();.
Example
String undefined This option should contain a unique namespace for each table; it is used when binding to event listeners (v2.15.7).

Notes about this namespace option:
  • If a namesspace is not defined, a (hopefully) unique random namespace will be generated.
  • If defined, any "non-word" characters (anything not "a-z", "0-9" or "_") within the namespace will be removed.
  • Added or not, the namespace will be saved with a leading period (e.g. ".myuniquetableid")
$(function(){
  $("#mytable").tablesorter({
    // if table id = "mytable", this namespace is saved as ".mytable"
    namespace : $('#mytable')[0].id;
  });
});
Function null Replace the default number sorting algorithm with a custom one using this option (v2.12).

Here is an example:
$(function(){
  $("table").tablesorter({
    numberSorter : function(a, b, direction, maxColumnValue){
      // direction; true = ascending; false = descending
      // maxColumnValue = the maximum value of that column (ignoring its sign)
      return a - b;
    }
  });
});
The direction parameter (boolean) is merely for informational purposes as the plugin automatically switches a and b depending on the sort direction ( i.e. there's no need to worry about reverse sorting, it's taken care of by the plugin ).
String "click" Use this option to change the click event (v2.22.0)

Change this option if want to change the click event that is bound to the table headers. Add multiple events separated by spaces.

Warning If this option is set to fire multiple events (e.g. 'mouseup pointerup'), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
String "mousedown" Use this option to change the pointer down event (v2.22.0)

Change this option if you're using pointer events (or the pointer events polyfill). Add multiple events separated by spaces.

Warning If this option is set to fire multiple events (e.g. 'mousedown pointerdown'), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
String "mouseup" Use this option to change the pointer up event (v2.22.0)

Change this option if you're using pointer events (or the pointer events polyfill). Add multiple events separated by spaces.

Warning If this option is set to fire multiple events (e.g. 'mouseup pointerup'), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
Function null Replace the default sorting algorithm with a custom one using this option (v2.27.6) - *NOTE* The parameters have changed!!.

Include a script like naturalSort.js as follows:
$(function(){
  $("table").tablesorter({
    textSorter : naturalSort
  });
});
or use the localeCompare sort
$(function(){
  $("table").tablesorter({
    // replace the OVERALL text sorter function
    textSorter: function(a, b, direction, columnIndex, table){
      // direction: true = ascending; false = descending
      // columnIndex: zero-based index of the current table column being sorted
      // table: table DOM element (access options by using table.config)
      return a.localeCompare(b);
    }
  });
});
In v2.27.6, the textSorter option will allow setting a sorter per column index or class name (column indexes were added in v2.12):
$(function(){
  $("table").tablesorter({
    textSorter : {
      // replace INDIVIDUAL COLUMN text sorter functions
      0 : function(a, b, direction, columnIndex, table){
        // same as $.tablesorter.sortText (basic alphabetical sort)
        // direction: true = ascending; false = descending
        // columnIndex: zero-based index of the current table column being sorted
        // table: table DOM element (access options by using table.config)
        return a > b ? 1 : (a < b ? -1 : 0);
      },
      // same as the function in column 0 above (modified in v2.12)
      1 : $.tablesorter.sortText,
      // renamed v2.12 from $.tablesorter.sortText - performs natural sort
      '.nat-sort' : $.tablesorter.sortNatural,
      // alphanumeric sort from sugar v2.0+ (https://sugarjs.com/docs/#/Array/getOption)
      '.sugar-sort' : Sugar.Array.getOption('sortCollate')
    }
  });
});
The direction parameter (boolean) is merely for informational purposes as the plugin automatically switches a and b depending on the sort direction ( i.e. there's no need to worry about reverse sorting, it's taken care of by the plugin ).
1 2
Boolean true Indicates how tablesorter should deal with a numerical format: (v2.1.3).
true U.S. 1,234,567.89
false German:
French:
1.234.567,89
1 234 567,89
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).
Prior to v2.4, this option set pixel widths to added colgroups to fix the column widths. This is useful for the Pager companion.
Requires the jQuery dimension plugin to work. This is now part of the jQuery core.
Example
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).

Previously documented widget options widgetZebra, widgetColumns and widgetUitheme will be retained for backwards compatibility.

Use the widgetOptions option as follows, please note that each option is followed by a comma (except the last one):
$(function(){
  $("table").tablesorter({

    // initialize a bunch of widgets (the order doesn't matter)
    widgets: ["zebra", "uitheme", "columns", "filter", "resizable", "stickyHeaders"],

    widgetOptions: {

      // *** COLUMNS WIDGET ***
      // change the default column class names primary is the 1st column
      // sorted, secondary is the 2nd, etc
      columns: [
        "primary",
        "secondary",
        "tertiary"
      ],

      // If true, the class names from the columns option will also be added
      // to the table tfoot
      columns_tfoot: true,

      // If true, the class names from the columns option will also be added
      // to the table thead
      columns_thead: true,

      // *** FILTER WIDGET ***
      // css class name added to the filter cell (string or array)
      filter_cellFilter: '',

      // 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;
      // default is false
      filter_childRows: false,

      // ( filter_childRows must be true ) if true = search
      // child rows by column; false = search all child row text grouped
      filter_childByColumn: false,

      // if true, include matching child row siblings
      filter_childWithSibs: true,

      // if true, allows using '#:{query}' in AnyMatch searches
      // ( column:query )
      filter_columnAnyMatch: true,

      // If true, a filter will be added to the top of each table column.
      filter_columnFilters: true,

      // css class name added to the filter row & each input in the row
      // (tablesorter-filter is ALWAYS added)
      filter_cssFilter: '',

      // data attribute in the header cell that contains the default (initial)
      // filter value
      filter_defaultAttrib: 'data-value',

      // add a default column filter type "~{query}" to make fuzzy searches
      // default; "{q1} AND {q2}" to make all searches use a logical AND.
      filter_defaultFilter: {},

      // filters to exclude, per column
      filter_excludeFilter: {},

      // jQuery selector string (or jQuery object)
      // of external filters
      filter_external: '',

      // class added to filtered rows; needed by pager plugin
      filter_filteredRow: 'filtered',

      // add custom filter elements to the filter row
      filter_formatter: null,

      // Customize the filter widget by adding a select dropdown with content,
      // custom options or custom filter functions;
      // see http://goo.gl/HQQLW for more details
      filter_functions: null,

      // hide filter row when table is empty
      filter_hideEmpty: true,

      // Set this option to true to hide the filter row initially. The row is
      // revealed by hovering over the filter row or giving any filter
      // input/select focus. In v2.26.6, a function can be used to set when
      // to hide the filter row.
      filter_hideFilters: false,

      // Set this option to false to keep the searches case sensitive
      filter_ignoreCase: true,

      // if true, search column content while the user types (with a delay)
      // or, set a minimum number of characters that must be present before
      // a search is initiated. In v2.27.3, this option can contain an
      // object with column indexes or classnames; "fallback" is used
      // for undefined columns
      filter_liveSearch: true,

      // global query settings ('exact' or 'match'); overridden by
      // "filter-match" or "filter-exact" class
      filter_matchType: {
        'input': 'exact',
        'select': 'exact'
      },

      // a header with a select dropdown & this class name will only show
      // available (visible) options within the drop down
      filter_onlyAvail: 'filter-onlyAvail',

      // default placeholder text (overridden by any header
      // "data-placeholder" setting)
      filter_placeholder: {
        search: '',
        select: ''
      },

      // jQuery selector string of an element used to reset the filters.
      filter_reset: null,

      // Reset filter input when the user presses escape
      // normalized across browsers
      filter_resetOnEsc: true,

      // Use the $.tablesorter.storage utility to save the most recent filters
      filter_saveFilters: false,

      // Delay in milliseconds before the filter widget starts searching;
      // This option prevents searching for every character while typing
      // and should make searching large tables faster.
      filter_searchDelay: 300,

      // allow searching through already filtered rows in special
      // circumstances; will speed up searching in large tables if true
      filter_searchFiltered: true,

      // include a function to return an array of values to be added to the
      // column filter select
      filter_selectSource: null,

      // filter_selectSource array text left of the separator is added to
      // the option value, right into the option text
      filter_selectSourceSeparator: '|',

      // Set this option to true if filtering is performed on the
      // server-side.
      filter_serversideFiltering: false,

      // 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; default is false
      filter_startsWith: false,

      // If true, ALL filter searches will only use parsed data. To only
      // use parsed data in specific columns, set this option to false
      // and add class name "filter-parsed" to the header
      filter_useParsedData: false,

      // *** 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
      resizable: true,

      // If this option is set to true, a resizing anchor
      // will be included in the last column of the table
      resizable_addLastColumn: false,

      // Set this option to the starting & reset header widths
      resizable_widths: [],

      // Set this option to throttle the resizable events
      // set to true (5ms) or any number 0-10 range
      resizable_throttle: false,

      // When true, the last column will be targeted for resizing,
      // which is the same has holding the shift and resizing a column
      resizable_targetLast: false,

      // *** 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.
      saveSort: true,

      // *** STICKYhEADERS WIDGET ***
      // stickyHeaders widget: extra class name added to the sticky header
      // row
      stickyHeaders: '',

      // jQuery selector or object to append sticky headers to
      stickyHeaders_appendTo: null,

      // jQuery selector or object to attach sticky headers scroll listener to
      // overridden by xScroll & yScroll settings
      stickyHeaders_attachTo: null,

      // jQuery selector or object to monitor horizontal scroll position
      // (defaults: xScroll > attachTo > window)
      stickyHeaders_xScroll: null,

      // jQuery selector or object to monitor vertical scroll position
      // (defaults: yScroll > attachTo > window)
      stickyHeaders_yScroll: null,

      // number or jquery selector targeting the position:fixed element
      stickyHeaders_offset: 0,

      // scroll table top into view after filtering
      stickyHeaders_filteredToTop: true,

      // added to table ID, if it exists
      stickyHeaders_cloneId: '-sticky',

      // trigger "resize" event on headers
      stickyHeaders_addResizeEvent: true,

      // if false and a caption exist, it won't be included in the
      // sticky header
      stickyHeaders_includeCaption: true,

      // The zIndex of the stickyHeaders, allows the user to adjust this
      // to their needs
      stickyHeaders_zIndex: 2,

      // *** STORAGE WIDGET ***
      // allows switching between using local & session storage
      storage_useSessionStorage: false,
      // alternate table id (set if grouping multiple tables together)
      storage_tableId: '',
      // table attribute to get the table ID, if storage_tableId
      // is undefined
      storage_group: '', // defaults to "data-table-group"
      // alternate url to use (set if grouping tables across
      // multiple pages)
      storage_fixedUrl: '',
      // table attribute to get the fixedUrl, if storage_fixedUrl
      // is undefined
      storage_page: '',

      // *** ZEBRA WIDGET ***
      // class names to add to alternating rows
      // [ "even", "odd" ]
      zebra: [
        "even",
        "odd"
      ]

    }

  });
});
Example
Utility Options
String "checked" Used by the "checkbox" parser in the parser-input-select.js file (v2.22.2; v2.25.0).

When using the checkbox parser, this class name is added to the row along with this class name plus the column index when the targeted checkbox is checked.

For example, if the named parser file has been loaded & "sorter-checkbox" class is added to the first column header, then any checked checkbox in the first column will have "checked checked-0" class names added to the row.

Checkboxes in any other column, not targeted by the parser, will be ignored and no extra row class names will be added.
Example
Boolean true Used by the "checkbox" parser in the parser-input-select.js file (v2.24.6).

When using the checkbox parser, this setting is used when a checkbox inside a header cell is changed; if true, only same column checkboxes within visible rows are modified to match the header checkbox.

If false, same column checkboxes in all rows are modified to match the status of the header checkbox.

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).

This option is meant to be used with the jQuery Globalize library along with CLDR data.

See the Globalization section in the group widget demo for details on how to set it up.

Currently, the globalize (parser-globalize.js), month (parser-date-month.js) & weekday (parser-date-weekday.js) parsers utilize this option.

$(function(){
  $('table').tablesorter({
    // globalize : { lang: 'en' } // for ALL columns
    // or, per column by using the column index
    globalize : {
      0 : { lang: 'fr', Globalize : Globalize('fr'), raw: 'MMM d, y G' },
      2 : { lang: 'fr' }
    }
  });
});
2 2
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).

Change this setting to grab a different image attribute to be used for sorting:
$(function(){
  $('table').tablesorter({
    // parse image title (value to be used while sorting & filtering)
    imgAttr : 'title',
    headers : {
      0 : { sorter: 'image' } // this parser is auto-detected, but will only work on the first image
    }
  });
});
Deprecated/Removed Options
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 added to set a specific page when storing data using the $.tablesorter.storage code (v2.12).
More specifically, when the storage function is used, it attempts to give every table a unique identifier using both the page url and table ID (or index on the page if no id exists). This option allows you to override the current page url (it doesn't need to be a url, just some constant value) and save data for multiple tables across a domain.

The table url & id can also be overridden by setting table data attributes data-table-page (url) and data-table-group (id)
(e.g. <table class="tablesorter" data-table-page="mydomain" data-table-group="financial">...</table>)

For a bit more detail, specifically on how to use the new storage function options for a custom widget, please refer to issue #389.
String This option was removed! It has been replaced by cssNoSort which does the opposite of what this class name was supposed to do.

This option was not working as intended, so it was completely removed - sorry for the lack of notice.

Previous default was "tablesorter-allowClicks"

Class name added to table header which allows clicks to bubble up. (added v2.18.1; removed in v2.20.0).
This option was removed in v2.21.2! It has been replaced by widgetOptions.columns.

Default value: { css: [ "primary", "secondary", "tertiary" ] } (Object with Array)

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)... (v2.0.17). Use the widgetColumns option to change the css class name as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["columns"], // initialize column styling of the table
    widgetColumns: { css: ["primary", "secondary", "tertiary" ] }
  });
});
This option was removed in v2.4! It has been replaced by widgetOptions.uitheme.

Default value: { css: [ "ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n" ] } (Object with Array)

Used when the ui theme styling widget is initialized. It automatically applies the default class names of "ui-icon-arrowthick-2-n-s" for the unsorted column, "ui-icon-arrowthick-1-s" for the descending sort and "ui-icon-arrowthick-1-n" for the ascending sort. (v2.0.9). Find more jQuery UI class names by hovering over the Framework icons on this page: http://jqueryui.com/themeroller/

Use the widgetUitheme option to change the css class name as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["uitheme"], // initialize ui theme styling widget of the table
    widgetUitheme: {
      css: [
        "ui-icon-carat-2-n-s", // Unsorted icon
        "ui-icon-carat-1-s",   // Sort up (down arrow)
        "ui-icon-carat-1-n"    // Sort down (up arrow)
      ]
    }
  });
});
This option was removed in v2.4! It has been replaced by widgetOptions.zebra.

Default value: { css: [ "even", "odd" ] } (Object with Array)

When the zebra striping widget is initialized, it automatically applied the default class names of "even" and "odd". Use the widgetZebra option to change the css class name as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["zebra"], // initialize zebra striping of the table
    widgetZebra: { css: [ "normal-row", "alt-row" ] }
  });
});

Widget & Pager Options

Widget PriorityNameRequires jQueryLimiting function
30columnsv1.2.6
50filterv1.4.31.4.3 (nextUntil & delegate)
Lastpager pluginv1.2.6
55pager widgetv1.71.7 (on)
40resizablev1.4.1*1.4.1 (parseJSON)*
20saveSortv1.4.11.4.1 (parseJSON)*
60stickyHeadersv1.4.31.4.3 (isWindow)**
10uithemev1.2.6
90zebrav1.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).

Use the "columns" option to change the css class name as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["columns"], // initialize column styling of the table
    widgetOptions : {
      columns: [ "primary", "secondary", "tertiary" ]
    }
  });
});
Example
Boolean true Columns widget: If true, the class names from the columns option will also be added to the table thead (v2.4).

Use the "columns_thead" option to add the column class names to the thead as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["columns"], // initialize column styling of the table
    widgetOptions : {
      columns_thead: true
    }
  });
});
Example
Boolean true Columns widget: If true, the class names from the columns option will also be added to the table tfoot (v2.4).

Use the "columns_tfoot" option to add the column class names to the tfoot as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["columns"], // initialize column styling of the table
    widgetOptions : {
      columns_tfoot: true
    }
  });
});
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).

*NOTE* When using this option, please be aware that all child row content will be obtained from each table cell using textContent, so none of the markup will be preserved. Also, carriage returns (<br>) will not be included. To account for the loss of white space, especially after carriage returns, please add an extra space to the end of the line. Using innerText, could have been an option for preserving the white space, but it is not standardized across all browsers (ref).

Use the filter_childRows option to include child row text as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_childRows : true
    }
  });
});
Boolean false Filter widget: If true, queries will search child row content by column (v2.22.0).

The filter_childRows option must also be true for this option to work.

If false, and the filter_childRows option is true, then queries in any column will search all child content, as before this option was added.

Use the filter_childByColumn option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_childRows : true,
      filter_childByColumn : true
    }
  });
});
Example
Boolean true Filter widget: include all sibling rows of the matching child row (v2.23.4).

Both filter_childRows & filter_childByColumn options must be set to true for this option to work.

If false, this option will only show the child row that matches the filter; and its parent row.

Use the filter_childWithSibs option as follows:
$(function(){
  $("table").tablesorter({
    widgets: [ "filter" ],
    widgetOptions : {
      filter_childRows     : true,
      filter_childByColumn : true,
      // only show matching child row & parent
      filter_childWithSibs : false
    }
  });
});
Example
Boolean true Filter widget: If true, allows using "#:{query}" in anyMatch searches (v2.20.0).

Users can use the anymatch input to target a specific column, using a one-based index.

For example: In the table below, searching for 2:aa in an anymatch filter will result in "Phillip Aaron Wong" and "Aaron" showing in the First Name column.

See live examples in the Filter Widget External Search demo.
Boolean true Filter widget: If true, a filter will be added to the top of each table column (v2.4).

Use the filter_columnFilters option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_columnFilters : true
    }
  });
});
String or Array "" Filter widget: Additional CSS class applied to each filter cell (v2.18.0).

When the filter row is built, each table cell (<td>) will get the class name from this option.
  • If this option is a plain string, all filter row cells will get the text applied as a class name.
    // "table-filter" class added to all filter row td's
    filter_cssFilter : 'table-filter'
  • If this option is an array, then each filter row cell will get the text from the associate array element applied as a class name.
    .hidden { display: none; }
    // hiding second & fourth columns using associated css
    filter_cssFilter : [ '', 'hidden', '', 'hidden' ]

Use the filter_cellFilter option to add an extra css class name as follows:

$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      // css class applied to the table row containing the filters & the inputs within that row
      // or [ "filter-cell0", "filter-cell1", "filter-cell2", etc... ]
      filter_cellFilter : "tablesorter-filter-cell"
    }
  });
});
Note The cells from this option are also contained within the config.$filters variable.
Example
String or Array "" Filter widget: Additional CSS class applied to each filter (v2.15).

As of v2.15, this option can also contain an array of class names that are to be applied to input filters.

Changed default to an empty string in v2.11, as the "tablesorter-filter" class will always be added to the filter; this option now contains any additional class names to add.

Use the filter_cssFilter option to add an extra css class name as follows:

$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      // css class applied to the table row containing the filters & the inputs within that row
      // or [ "filter0", "filter1", "filter2", etc... ]
      filter_cssFilter : "tablesorter-filter"
    }
  });
});
Example
Object { } Filter widget: Add a default filter type to a column (v2.17.8).

Warning If a column has a default filter set, the user will not be able to use other filters.

Use the filter_defaultFilter option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {

      filter_defaultFilter : {
        // target a column by class name or column index (zero-based)

        '.fuzzy' : '~{q}',
        2 : '{q}=',

        // for default "anyMatches" use the column length as the index
        // e.g. if your table has 5 columns (0,1,2,3,4), then set the anyMatch column as 5.
        5 : '{q} or {q}' // any match column
      }

    }
  });
});
Set up the column string as follows:
  • Add the desired filter type symbol along with {query} or {q} to maintain positioning
  • Symbols can be added to the beginning "~{query}" (default fuzzy search) or end "{q}=" (default exact search)
  • For symbols that separate queries, like "AND", "OR" or "-" (range):
    • Add one additional {q} tag.
    • For example, to add a default "OR" search, use "{q} OR {q}".
    • If the user enters "a b c d" the column will be filtered using "a OR b OR c OR d", so there is no need to add more {q} tags within the string; adding more will likely mess up the results.
    • If the user only enters "a", then the column will be filtered using "a OR a" so as not to cause other issues.
  • Note It is not possible to set up a default filter search within a query. So the "wild" filter search will not work as intended (e.g. {q}* and {q}? are essentially the same as {q}.
Example
Object { } Filter widget: Additional CSS class applied to each filter (v2.17.8). Exclude a filter type(s) for a column.

Use the filter_excludeFilter option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {

      filter_excludeFilter : {
        // target a column by class name or column index (zero-based)
        '.title' : 'range',

        // separate multiple filter types using spaces
        2 : 'range notMatch exact'
      }

    }
  });
});
Exclusion names must be separated by a comma. Here is a full list of filter type names:
  • and - logical AND type filter (using foo AND bar or foo && bar).
  • or - logical OR type filter (using foo OR bar or foo|bar).
  • exact - exact match (using " or =).
  • fuzzy - fuzzy match (~)
  • notMatch - not match (! or !=)
  • operators - comparison filters (< <= >= >)
  • range - range ( - or to )
  • regex - regex (/\d/)
  • wild - wild card matching (? for single characters, * for multiple characters not including spaces, or | or OR for a logical OR (the "or" filter type was separated from "wild" in v2.22.2).
String "" Filter widget: jQuery selector string of inputs, outside of the table, to be used for searching table content (v2.15).

Set this option to be a jQuery selector string, or jQuery object, pointing to any external inputs that are to be used for searching the table.

Use the filter_external option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_external : '.search'
    }
  });
});
These external inputs have one requirement, they must have a data-column="#", where the # targets the column (zero-based index), pointing to a specific column to search.
<input class="search" type="search" data-column="0" placeholder="Search first column">
If you want to search all columns, using the updated "any match" method, set the data column value to "all":
<input class="search" type="search" data-column="all" placeholder="Search entire table">
The updated any matching code will now automatically update all associated inputs with the latest search.
This option replaces filter_anyMatch.
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).

*NOTE* If creating a custom theme, make sure to include this definition (set to display:none or the filter widget will appear to be broken!
Object null Filter widget: This option allows you to add custom controls within the filter widget row (v2.7.7; v2.17.0).

In v2.17.0, the filter_formatter column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table header cell.
filter_formatter : {
    ".col-value" : function($cell, indx){
      return $.tablesorter.filterFormatter.uiSpinner( $cell, indx, {
        ...
      });
    }
}
Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

A new file has been included named "widget-filter-formatter-jui.js" & "widget-filter-formatter-html5.js". The files include code to add jQuery UI and HTML5 controls via the filter_formatter option.

Most of the formatter functions have an option named valueToHeader which, when true adds a span to the header cell above the filter row and updates it with the current control's value (see example 2). If the option exists and is set to false, then the current value is added to the control's handle and css can be used to create a popup to show the current value (see example 1).

Another custom option named addToggle is included with the "uiSpinner", "html5Color" and "html5Number" code. This allows the user to disable the control to show all table rows. For the single sliders, "uiSlider" and "html5Range", the minimum value is used to clear the filter (show all rows).

The options included for each jQuery UI control only show basic options, but any or all of the jQuery UI options for that control can be included.
  • To add the jQuery UI slider, follow this example:
    $(function(){
      $("table").tablesorter({
        widgets: ["filter"],
        widgetOptions : {
          filter_formatter : {
            // column index `0` or use a jQuery selector `"th:contains('Discount')"`
            0 : function($cell, indx){
              return $.tablesorter.filterFormatter.uiSpinner( $cell, indx, {
                value : 0,  // starting value
                min   : 0,  // minimum value
                max   : 50, // maximum value
                step  : 1,  // increment value by
                addToggle: true, // Add a toggle to enable/disable the control
                valueToHeader: false // add current slider value to the header cell
              });
            }
          }
        }
      });
    });
    Any of the other jQuery UI spinner widget options can also be included.

  • Filter formatter functions include: "uiSpinner", "uiSlider", "uiRange" (uiSlider ranged), "uiDatepicker" (range only), "html5Number", "html5Range" and "html5Color".
  • For other examples, please refer to the example pages. Formatter part 1 (example 1) adds jQuery UI controls to the filter row, while formatter part 2 (example 2) adds HTML5 controls, if supported, to the filter row.
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).

In v2.22.0, a data parameter was added to that long list of parameters.

*WARNING* In a future update, the filter function parameters will be cleaned up and changed as follows!
filter_functions : {
  // function(e, n, f, i, $r, c, data) {} <- current parameters
  0 : function(c, data) {} // planned change (version undetermined)
}
The e (exact table cell text), n (normalized table cell text), f (filter input value), i (column index) and $r (current row; jQuery object) are all already included in the data object.

In v2.17.0, the filter_functions column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table header cell.
filter_functions : {
    ".col-date" : {
        "< 2004" : function (e, n, f, i, $r, c, data) {
            return n < Date.UTC(2004, 0, 1); // < Jan 1 2004
        },
        ...
    }
}
Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

Use the "filter_functions" option in three different ways:
  • Make a sorted select dropdown list of all column contents. Repeated content will be combined.
    $(function(){
      $("table").tablesorter({
        widgets: ["filter"],
        widgetOptions: {
          filter_functions: {
            // Add select menu to this column
            // set the column value to true, and/or add "filter-select" class name to header
            0 : true
          }
        }
      });
    });
    Alternately, instead of setting the column filter funtion to true, give the column header a class name of "filter-select". See the demo.

  • Make a select dropdown list with custom option settings. Each option must have a corresponding function which returns a boolean value; return true if there is a match, or false with no match.

    Regex example

    $(function(){
      $("table").tablesorter({
        widgets: ["filter"],
        widgetOptions: {
          // function variables:
          // e = exact text from cell
          // n = normalized value returned by the column parser
          // f = search filter input value
          // i = column index
          // $r = jQuery element of current row
          // c = table.config
          // data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
          filter_functions: {
            // Add these options to the select dropdown (regex example)
            2 : {
              "A - D" : function(e, n, f, i, $r, c, data) { return /^[A-D]/.test(e); },
              "E - H" : function(e, n, f, i, $r, c, data) { return /^[E-H]/.test(e); },
              "I - L" : function(e, n, f, i, $r, c, data) { return /^[I-L]/.test(e); },
              "M - P" : function(e, n, f, i, $r, c, data) { return /^[M-P]/.test(e); },
              "Q - T" : function(e, n, f, i, $r, c, data) { return /^[Q-T]/.test(e); },
              "U - X" : function(e, n, f, i, $r, c, data) { return /^[U-X]/.test(e); },
              "Y - Z" : function(e, n, f, i, $r, c, data) { return /^[Y-Z]/.test(e); }
            }
          }
        }
      });
    });

    Comparison example

    $(function(){
      $("table").tablesorter({
        widgets: ["filter"],
        widgetOptions: {
          // function variables:
          // e = exact text from cell
          // n = normalized value returned by the column parser
          // f = search filter input value
          // i = column index
          // $r = jQuery element of current row
          // c = table.config
          // data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
          filter_functions: {
            // Add these options to the select dropdown (numerical comparison example)
            // Note that only the normalized (n) value will contain numerical data
            // If you use the exact text, you'll need to parse it (parseFloat or parseInt)
            4 : {
              "< $10"      : function(e, n, f, i, $r, c, data) { return n < 10; },
              "$10 - $100" : function(e, n, f, i, $r, c, data) { return n >= 10 && n <=100; },
              "> $100"     : function(e, n, f, i, $r, c, data) { return n > 100; }
            }
          }
        }
      });
    });
    Note: if the filter_ignoreCase option is true, it DOES alter the normalized value (n) by making it all lower case.

  • Make a custom filter for the column.
    $(function(){
      $("table").tablesorter({
        widgets: ["filter"],
        widgetOptions: {
          // function variables:
          // e = exact text from cell
          // n = normalized value returned by the column parser
          // f = search filter input value
          // i = column index
          // $r = jQuery element of current row
          // c = table.config
          // data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
          filter_functions: {
            // Exact match only
            1 : function(e, n, f, i, $r, c, data) {
              return e === f;
            }
          }
        }
      });
    });
    Note: if the filter_ignoreCase option is true, it DOES alter the normalized value (n) by making it all lower case.

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).

Use the filter_hideEmpty option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_hideEmpty : false
    }
  });
});
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).

Use the filter_hideFilters option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_hideFilters : true
    }
  });
});
You can change the style (thickness) of the hidden filter row in the tablesorter theme css. Look for .tablesorter-filter-row (revealed row) and .tablesorter-filter-row.hideme (for the hidden row) css definitions. In v2.26.6, this setting can also contain a function.
  • When this function returns a boolean value, it signifies whether the filter row should or should not be hidden (see the details in this issue.
  • If this function does not return a boolean value, the value of the filters are checked and if no search queries are found, the filter row will be hidden.
Example of function setting:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_hideFilters : function(config) {
        // get an array of filter queries (don't use the value from
        // `config.lastSearch` because this code will modify it;
        // unless you extend it)
        var search = $.tablesorter.getFilters(config.$table);
        // ignore any query is column 2 (zero-based index)
        search.splice(2,1);
        // return true to hide the filter row, false to show it
        return search.join("") === "";
      }
    }
  });
});
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)

Use the filter_ignoreCase option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_ignoreCase : false
    }
  });
});
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).

This option, when false allows you to disable the live search behavior, so that a filter is only applied when the user presses Enter (or uses Esc to clear and cancel the search).

If this option is set to a number, e.g. 4, a search of the column content will not initiate until this minimum number of characters are entered into the input.

In v2.27.3, this option can be set as an object containing specific column zero-based indexes, or class names. For undefined columns, include a "fallback" value otherwise undefined columns will be set as false.

$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_liveSearch : {
        // when false, the user must press enter to blur the input to trigger the search
        3 : false,
        // the query will initiate when 5 or more characters are entered into the filter
        4 : 5,
        // no live search on the last three columns (using a header class name)
        '.last-3-columns' : false,
        // for columns that aren't defined; this will set the fallback value
        // otherwise the fallback defaults to false.
        'fallback' : true
      }
    }
  });
});
Object { 'input': 'exact', 'select': 'exact' } Filter widget: This option sets the global setting that applied to either input or select filters (v2.25.5)

A basic input filter will match the filter query until a "and" and "or" type search is performed.

By default, select filters and "and" and "or type searchs will look for an exact match, and to override this behavior you *had* to add a "filter-match" class to the columns to allow partial matches.

This option allows you to set a global "match" setting and save you the trouble of adding a bunch of classes.

There are only two options: "exact" and "match"; and it defaults to "exact" if anything else is entered.

In the demo, try searching for super or man in the first column.
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).

In v2.17.6, columns with the only available class name set, that are not currently being filtered will only show the available options. Conversely, the column(s) with a selected option will show all options.

This option is useful after one or more columns have been filtered, then the column select filter with this class applied will only show the contents of the column within the dropdown that are currently visible. See the custom filter widget demo "Discount" column for an example (sort the "First Name" column first).

Caution: The main issue with this functionality is with keyboard accessibility. If the keyboard is used to select an option, only the first and default options will be available for chosing. The only way to select other options is with the mouse.
Example
object { search : '', select : '' } Filter widget: Set global filter input placeholder text for search inputs and selects (v2.16).

Any search type input added to the filter row will automatically get a placeholder attribute added, the source of this placeholder text is from the following sources, in order of priority:
  • Header cell data (table.config.$headers.eq(0).data('placeholder', 'search for...');
  • Header cell data-attribute (<th data-placeholder="Find Rank...">Rank</th>)
  • Global filter_placeholder.search setting.
The filter_placeholder.select setting adds the text to the first select option (default option to show all rows).

Note: The widget-filter-formatter-jui.js jQuery UI Datepicker Range Selector creates two inputs, so this option then includes two additional settings:

filter_placeholder : {
	search : '',
	select : '',
	from   : '', // datepicker range "from" placeholder
	to     : ''  // datepicker range "to" placeholder
}
Note: The browser must support the placeholder attribute before it will be visible.
Example
String, jQuery object null Filter widget: jQuery selector string of an element used to reset the filters (v2.4; v2.16).

When this option points to a reset element using a jQuery selector string, it is bound using event delegation. So if any additional reset elements, with the same class name, are added to the page dynamically, they will be associated with the same table.

For example, add this button (<button class="reset">Reset</button>) to the table header, or anywhere else on the page. That element will be used as a reset for all column and quick search filters (clears all fields):

Use the filter_reset option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_reset : '.reset'
    }
  });
});
If this option contains a jQuery object (v2.16), clicking on any of the elements within that jQuery object will trigger a filter reset. If any additional elements with the same selector are added to the page, they will not be dynamically functional.

If either of these methods do not work as desired, simply trigger a filterReset event on the table.
Example
Boolean true Filter widget: when true, normalize pressing escape to clear filter input across browsers (v2.25.2).

Webkit browsers automatically clear the filter search input when pressing escape, but IE and Firefox do not. Setting this option to true, clears the filter input when the user presses escape.

When this option is set to false, pressing escape inside the search field is ignored.
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).

Filters saved to local storage (or cookies) will override any default filters within the header data-attribute (set by the filter_defaultAttrib option) and be available to the pager before any ajax calls are made.

To bypass this behavior, clear out the saved filters as follows:
$.tablesorter.storage( $('table'), 'tablesorter-filters', '' );
Example
Numeric 300 Filter widget: Set this option to the number of milliseconds to delay the search. (v2.3.4).

Use the filter_searchDelay option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_searchDelay : 500
    }
  });
});
If you want to want to initialize the filter without user input, target any one of the filters and trigger a "search".
// target the first filter input
// this method will begin the search after the searchDelay time
$('input.tablesorter-filter:eq(0)').trigger('search');

// this method will begin the search immediately
$('input.tablesorter-filter:eq(0)').trigger('search', false);
In tablesorter v2.4+, the trigger can be applied directly to the table:
// refresh the widget filter; no delay
$('table').trigger('search', false);
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).

To better explain this, lets do it by example. Lets say you have a column of color names and you enter "light" and results like "light blue" and "light grey" show up.

When you press the space bar, a space is added, and instead of searching though all of the colors again, the filter widget only searches through the already filtered results that started with "light". This can substantially speed up searching, especially in large tables.

But, there are some special circumstances which would make this method return incorrect results. So, this option was added to allow you to disable this feature in case one of these following conditions doesn't cover your need; but still, please report any issues!

The search through filtered results only occurs if the following conditions are met:
  • The last search (for all columns) was not completely empty - all rows will be searched anyway.
  • If there were no changes to the search from the beginning of the search string (changing the above search to "bright" will force a new search of all rows).
  • If the search does not contain a logical or ( or or |), or a range delimiter ( - or to ) within the search query.
  • If the search is not looking for an exact match (" or =) or a logical not search (!).
  • Or, if the search is using a select dropdown without a "filter-match" class name (looking for an exact match).
  • If the search does not contain an operator greater than or equal to a negative number (>=-10) or less than or equal to a positive number (<=10).
  • And lastly, only search filtered rows if all rows are not hidden.
If the debug option is set to true, then a message will appear while filtering stating the specific number of rows, or "all" rows, that are being searched.

Use the filter_searchFiltered option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_searchFiltered : false
    }
  });
});
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.24.4).

In v2.24.4, this option will now accept an array of objects which can contain extra information for each option. Here is an example modified from the filter selectmenu demo:
filter_selectSource  : {
  0 : [
    { value : '/\\.js$/',            'data-class' : 'ui-icon-script',   text : 'javascript' },
    { value : '/\\.(jpg|png|gif)$/', 'data-class' : 'ui-icon-image',    text : 'Image' },
    // plain strings are also acceptable - the string is added to both the text & value attribute
    'foobar',
    { value : '.css',                'data-class' : 'ui-icon-note',     text : 'CSS' },
    { value : '.html',               'data-class' : 'ui-icon-document', text : 'HTML page' },
    { value : '/\\.(json|txt|md)$/', 'data-class' : 'ui-icon-help',     text : 'Misc' },
  ]
}
  • Each object entry must include a text property, or it will get ignored.
  • If no value property is set, the option value will be equal to the text (IE requires a value defined for every option).
  • Plain strings are still allowed within the array. If included, both the option text & value attribute will contain the string.
  • *NOTE* when returning an array containing objects, the options will not be reduced to obtain unique selections.
  • *NOTE* because this example is providing a fixed select option source, it can not support "filter-onlyAvail" (only show available options after filtering).

In v2.27.7, an option to have a descending sort applied to this data can be done by adding a "filter-select-sort-desc" to the header cell. Adding a "filter-select-nosort" class name to a header to prevent sorting has been available since v2.16.3.

In v2.21.5, this option will now override the filter_function options (so you need to add them back!), allowing the addition of custom select options and still maintain basic filtering action - see this demo (ref).

In v2.17.0, the filter_selectSource column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table header cell.
filter_selectSource : {
  ".model-number" : [ "abc", "def", "ghi", "xyz" ]
}
Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

A column will have a filter select dropdown when a "filter-select" class name is added to the header cell, or if the filter_functions column value is set to true

This option allows using an alternate source, or customizing options of the filter select dropdown. This option can be set as follows:
  • null - this value will set the default behavior and return all table cell values from the current column.
  • An overall function - when this option is a function, it will be used for all filter selects in the table.
    $(function(){
      $("table").tablesorter({
        widgets: ["filter"],
        widgetOptions : {
          filter_selectSource : function(table, column, onlyAvail){
            // get an array of all table cell contents for a table column
            var array = $.tablesorter.filter.getOptions(table, column, onlyAvail);
            // manipulate the array as desired, then return it
            return array;
          }
        }
      });
    });
  • An object containing column keys set with a function - when the option is set in this manner, a function can be applied to a specific column.

    This example was updated in v2.23.4 to use the buildSelect function directly (ref)

    $(function(){
      $("table").tablesorter({
        widgets: ["filter"],
        widgetOptions : {
          filter_selectSource : {
            0 : function(table, column, onlyAvail){
              // call ajax after tablesorter has initialized; this prevents
              // multiple ajax calls during initialization
              if (table.hasInitialized) {
                $.getJSON('ajax/options.json', function(data) {
                  // return false if there is a problem and the select
                  // will display the original defaults
                  var result = data.hasOwnProperty('options') ? data.options : false;
                  // if not already done on the server-side & you want to sort & remove duplicates
                  // from the results, use the processOptions function (added 2.23.4)
                  result = $.tablesorter.filter.processOptions( table, column, result );
                  // call the buildSelect function; pass `true` to replace the contents of the select
                  $.tablesorter.filter.buildSelect( table, column, result, true, onlyAvail );
                });
              }
              return false;
            }
          }
        }
      });
    });
The function uses the following parameters:
  • table - table DOM element
  • column - zero-based index of the column with a filter select
  • onlyAvail - boolean indicating if the returned options should only be from available (non-filtered) rows.
Important Return an array of values which will be added to the filter select dropdown. This array will automatically be stripped of any duplicate values and sorted alphanumerically before being added to the select. If for some reason the custom filter_selectSource function does not obtain the desired array of values, return false and the original method of obtaining column cell content will be used.
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.

Use the filter_selectSourceSeparator option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_selectSource : {
        0 : [ 'en|English', 'fr|French', 'de|German' ]
      },
      // filter_selectSource array text left of the separator is added to the option value, right into the option text
      filter_selectSourceSeparator : '|'
    }
  });
});
Results in this HTML:
<select>
	<option value=""></option>
	<option value="en">English</option>
	<option value="fr">French</option>
	<option value="de">German</option>
</select>
This also works for the filter_functions
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions: {
      filter_functions: {
        // Add these options to the select dropdown (regex example)
        1 : {
          "<10|Less than 10" : function(e, n, f, i, $r, c, data) { return n < 10; },
          "10 - 100|Between 10 & 100" : function(e, n, f, i, $r, c, data) { return n >= 10 && n <=100; },
          ">100|Greater than 100" : function(e, n, f, i, $r, c, data) { return n > 100; }
        }
      },
      // filter_selectSource array text left of the separator is added to the option value, right into the option text
      filter_selectSourceSeparator : '|'
    }
  });
});
Results in this HTML (this adds a data-function-name attribute to keep a reference to the associated filter_functions.
<select>
  <option value=""></option>
  <option data-function-name="&lt;10|Less than 10" value="&lt;10">Less than 10</option>
  <option data-function-name="10 - 100|Between 10 &amp; 100" value="10 - 100">Between 10 & 100</option>
  <option data-function-name="&gt;100|Greater than 100" value="&gt;100">Greater than 100</option>
</select>
Boolean false Filter widget: Set this option to true if filtering is performed on the server-side (v2.5.3).

Use the filter_serversideFiltering option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_serversideFiltering : true
    }
  });
});
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).

Use the filter_startsWith option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_startsWith : true
    }
  });
});
Example
Boolean false Filter widget: If true, ALL filter searches will only use parsed data (v2.4).

Use the filter_useParsedData option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_useParsedData : false
    }
  });
});
  • To only use parsed data in specific columns, set this option to false and use any of the following (they all do the same thing), set in order of priority:
    • jQuery data data-filter="parsed".
    • metadata class="{ filter: 'parsed'}". This requires the metadata plugin.
    • headers option headers : { 0 : { filter : 'parsed' } }.
    • header class name class="filter-parsed".
  • Remember that parsed data most likely doesn't match the actual table cell text, 20% becomes 20 and Jan 1, 2013 12:01 AM becomes 1357020060000.
String "data-value" Filter widget: This option contains the name of the data-attribute which contains the default (starting) filter value (v2.10.8).

Use the filter_defaultAttrib option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_defaultAttrib : 'data-value'
    }
  });
});
Then add the default filter value to the table header as follows:
<th data-value="<30">Age</th>
Example
String "" Sticky Headers widget: This additional CSS class applied to the sticky header row (v2.11).

Changed to empty string in v2.11, as the "tablesorter-stickyHeader" class will always be added to the sticky header row; this option now contains any additional class names to add.

Previously, this option contained the class name to be applied to the sticky header row (tr) (v2.1).

Use the "stickyHeaders" option to add an extra css class name as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // css class name applied to the sticky header
      stickyHeaders : "tablesorter-stickyHeader"
    }
  });
});
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).

So if your table ID is "gummy", then the cloned sticky table id becomes "gummy-sticky"

Use the "stickyHeaders_cloneId" option to change the cloned table id as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // cloned table id suffix
      stickyHeaders_cloneId : "-clone"
    }
  });
});
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).

Use the stickyHeaders_includeCaption option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // cloned table id suffix
      stickyHeaders_includeCaption : false
    }
  });
});
Example
String, jQuery Object null Sticky Headers widget: jQuery selector or object to physically attach the sticky headers (v2.27.0).

Note Appending the sticky headers to an element that does not have the same dimensions (width) as the table wrapper will produce a sticky header that does not match the table size!

Use the stickyHeaders_appendTo option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // Where to attach the stickyHeaders
      stickyHeaders_appendTo : '.wrapper' // $('.wrapper') jQuery object can also be used
    }
  });
});
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).

Use the stickyHeaders_attachTo option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // Where to attach the stickyHeaders
      stickyHeaders_attachTo : '.wrapper' // $('.wrapper') jQuery object can also be used
    }
  });
});
Example
String, jQuery Object null Sticky Headers widget: points to the element in which to monitor for horizontal scrolling (v2.18.0).

If undefined (or null), the window element will be monitored.

Use the stickyHeaders_xScroll option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // jQuery selector or object to monitor horizontal scroll position (defaults: xScroll > attachTo > window)
      stickyHeaders_xScroll : '.wrapper' // $('.wrapper') jQuery object can also be used
    }
  });
});
Example
String, jQuery Object null Sticky Headers widget: points to the element in which to monitor for vertical scrolling (v2.18.0).

If undefined (or null), the window element will be monitored.

Use the stickyHeaders_yScroll option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // jQuery selector or object to monitor vertical scroll position (defaults: yScroll > attachTo > window)
      stickyHeaders_yScroll : '.wrapper' // $('.wrapper') jQuery object can also be used
    }
  });
});
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).

If the page includes a fixed navigation bar at the top, like Bootstrap, set "stickyHeaders_offset" option to offset the sticky table header to be below the fixed navigation by setting this option using any of the following examples:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // apply sticky header top 30px below the top of the browser window
      stickyHeaders_offset : 30
    }
  });
});
or
stickyHeaders_offset : '.navbar-fixed-top' // jQuery selector string
or
stickyHeaders_offset : $('.navbar-fixed-top') // jQuery object
Boolean true Sticky Headers widget: Scroll table top into view after filtering (v2.16.2).

When a user searches the table using the sticky header filter row the results may reduce the number of rows so that the table would scroll up out of the viewport. So, this option scrolls the table top into view and moves the filter focus to the same input in the original header, instead of the sticky header input.

Set this option to false to prevent the page scroll after filtering the table.
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).

While this option is true, a timer is initialized to check the width of every header cell every 1/4 second. If this causes lag, or any other problems, set this option to false. When this option is false, sticky table headers are unable to detect and match the width of the original table headers when content is added or removed.

Use the "stickyHeaders_addResizeEvent" option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["resizable"],
    widgetOptions : {
      // add header resize detection
      stickyHeaders_addResizeEvent : true
    }
  });
});
When the browser window is resized, the headers (original and sticky) will resize automatically no matter the value of this option.
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).

Use the stickyHeaders_zIndex option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["stickyHeaders"],
    widgetOptions : {
      // The zIndex of the stickyHeaders, allows the user to adjust this to their needs
      stickyHeaders_zIndex : 100
    }
  });
});
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).

Use the "resizable" option to not save the resized widths:
$(function(){
  $("table").tablesorter({
    widgets: ["resizable"],
    widgetOptions : {
      // css class name applied to the sticky header
      resizable : false
    }
  });
});
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).

If an anchor was included and the table is full width, the column would resize in the opposite direction which my not be intuitive to the user. So set this option as desired, but please be mindful of the user experience.

Use the "resizable_addLastColumn" option to include the last column resizer as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["resizable"],
    widgetOptions : {
      // css class name applied to the sticky header
      resizable_addlastcolumn : true
    }
  });
});
Example
Array [] Resizable widget: Set this option to the starting & reset header widths (v2.15.12).

Use the "resizable_widths" option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["resizable"],
    widgetOptions : {
      // headers widths applied at initialization & resizable reset
      // this setting includes any non-resizable cells (resizable-false)
      resizable_widths : [ '10%', '10%', '50px' ]
    }
  });
});
Example
Boolean false Resizable widget: Set this option to throttle the resizable events (v2.17.4).

When false throttling of the mousemove (resizing) event is not applied.

Set this option to either true for a default 5 millisecond delay, or set it to any number less than 10 to adjust the throttling delay that is applied to the mousemove/resizing event.

Use the "resizable_throttle" option as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["resizable"],
    widgetOptions : {
      // set to true for a default 5ms throttling delay
      // or set to a number < 10 (more than that makes the resizing adjustment unusable
      resizable_throttle : true
    }
  });
});
Boolean false Resizable widget: When true, the last column will be targeted for resizing (v2.21.3).

When true, resizing a column will change the size of the selected column, and the last column, not the selected column's neighbor.

When false, resizing a column will move the column border between it's neighbors.

Also, in a full width table, if this option is false, the same behavior as when this option is true can be seen when resizing a column while holding down the Shift key on the keyboard - the last column is resized.

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).

Use the "saveSort" option to not save the current sort:
$(function(){
  $("table").tablesorter({
    widgets: ["saveSort"],
    widgetOptions : {
      // if false, the sort will not be saved for next page reload
      saveSort : false
    }
  });
});
Example
Boolean false Storage widget: If this option is set to false, all saved variables for the table will be within local storage (v2.21.3).

If true, all saved variables for the table will be within the session storage. This means once the user closes the browser, all saved variables are lost.

Use the "storage_useSessionStorage" option to switch to session storage as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["saveSort"],
    widgetOptions : {
      // if false, saved variables will be saved in local storage
      storage_useSessionStorage : true
    }
  });
});
Example
String "" Storage widget: This option allows setting an alternate table id so multiple tables on a page have the settings grouped together

When grouping together multiple tables, setting the variable on one table will not cause the setting to modify a second table, the change will only be apparent on page reload.

If this option is not defined, the actual table id will be used (which isn't conducive to applying to multiple tables!)

A more detailed list of the table id priority settings can be found in the $.tablesorter.storage function description.

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.

If a value is set in this option, the storage widget looks in that defined table data-attribute for a table id.

If this option is not defined, then the default data-attribute for the table becomes "data-table-group".

The value in the data-attribute sets a table id, if not found, the storage widget then looks for an id in the storage_tableId option.

String "" Storage widget: This option allows setting an alternate table url so that tables on multiple pages will have their settings grouped together

This option replaces and will override the now deprecated config.fixedUrl option.

If there is a value within the table's "data-table-page" (set by the storage_page option), it will override this setting.

A more detailed list of the table url priority settings can be found in the $.tablesorter.storage function description.

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.

If a value is set in this option, the storage widget looks in that defined table data-attribute for a table url.

If this option is not defined, then the default data-attribute for the table becomes "data-table-page".

The value in the data-attribute sets a table url, if not found, the storage widget then looks for a url in the storage_fixedUrl option.

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).

Use the "zebra" option to change the theme as follows:
$(function(){
  $("table").tablesorter({
    widgets: ["zebra"], // initialize zebra striping of the table
    widgetOptions: {
      zebra: [ "normal-row", "alt-row" ]
    }
  });
});
Example
Pager
Object null Target your one or more pager markup blocks by setting this option with a jQuery selector.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.container; additionally you can change the class name that is applied to the pager (used within the jquery.tablesorter.pager.css file) by modifying the widgetOption.pager_css.container class name (default is "tablesorter-pager")

This is some example pager markup. It should contain all of the controls set by the multiple css-named options:
<div class="pager">
  <form>
    <img src="first.png" class="first"/>
    <img src="prev.png" class="prev"/>
    <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
    <img src="next.png" class="next"/>
    <img src="last.png" class="last"/>
    <select class="pagesize">
      <option value="10">10</option>
      <option value="20">20</option>
      <option value="30">30</option>
      <option value="40">40</option>
    </select>
    <select class="gotoPage" title="Select page number"></select>
  </form>
</div>
Caution If you use buttons in your pager container, make sure the buttons include a button type (<button type="button">Next</button>) to prevent form submission and page reloading every time the button is clicked.

Use this option as follows:
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      container: $(".pager")
    });
});
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).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_ajaxUrl

The tags within the ajaxUrl string are optional. If do not want the user to change the page size, then you only need to include the page in this string:
ajaxUrl: "http://mydatabase.com?start={page}"
If you need to send your server a page offset (actual starting record number), then you'll need to use the customAjaxUrl option.

Here is an example of how to include the option, it should always be paired with an ajaxProcessing function:
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      ajaxUrl: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}",
      ajaxProcessing: function(data, table, xhr){
        // do something with the ajax data
        return [ formatted_data, total_rows ];
      }
    });
});
The ajaxUrl template replaces the following tags with values from the tablesorter plugin and pager addon:
TagReplaced with
{page}Zero-based index of the current pager page
{page+1}One-based index of the current pager page (replace "+1" with any number) (e.g. {page+3}) (v2.9).
{size}Number of rows showing, or number of rows to get from the server
{sortList:col} or {sort:col} Adds the current sort to the ajax url string into a "col" array, so your server-side code knows how to sort the data (v2.4.5).
The col portion of the {sortList:col} tag can be any name string (no spaces) to indicate the name of the variable to apply. So if your current sortList is [[2,0],[3,0]], it becomes "&sort[2]=0&sort[3]=0" in the url. {sort:col} shortened tag also works (v2.9).
{filterList:fcol} or {filter:fcol} Adds the value of the current filters to the ajax url string into a "fcol" array, so your server-side code knows how to filter the data (v2.6).
The fcol portion of the {filterList:fcol} tag can be any name string (no spaces) to indicate the name of the variable to apply. So if your current filters are ['','Blue',13], it becomes "&fcol[2]=Blue&fcol[3]=13" in the url. {filter:col} shortened tag also works (v2.9).
Example
Function function(table, url) { return url; } This callback function allows you to modify the processed URL as desired (v2.8.1).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_customAjaxUrl

The customAjaxUrl function has two parameters, the table DOM element and the processed url string (all tags within the ajaxUrl have been replaced with their appropriate values).
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      ajaxUrl: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}",
      ajaxProcessing: function(data, table, xhr){
        // do something with the ajax data
        return [ formatted_data, total_rows ];
      },
      // modify the url after all processing has been applied
      customAjaxUrl: function(table, url) {
        // trigger my custom event
        $(table).trigger('changingUrl');
        // send the server the current page
        return url += '&currntUrl=' + window.location.href;
      }
    });
});
In the following example, lets say your server needs a starting and ending record number instead of a page & size parameter. Use this option as follows:
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      ajaxUrl: "http://mydatabase.com?{sortList:col}",
      customAjaxUrl: function(table, url) {
        var pager = table.config.pager,
          start = pager.page * pager.size,
          end = start + pager.size;
        return url += '&start=' + start + '&end=' + end;
      },
      ajaxProcessing: function(data, table, xhr){
        // do something with the ajax data
        return [ total_rows, data ];
      }
    });
});
Example
Object { dataType: 'json' } This option contains the ajax settings for the pager interaction with your database (v2.10).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_ajaxObject

The ajaxObject is completely customizable, except for the url setting which is processed using the pager's ajaxUrl and customAjaxUrl options. This means you can also add a success callback function which is called after the ajax has rendered.

Your server does not need to return a JSON format, if you want to return pure HTML, set the dataType to "html" and modify the ajaxProcessing function to instead work with HTML; then return a jQuery object or apply the HTML to the table yourself.

See all possible settings in the jQuery.ajax documentation
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      ajaxUrl: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}",
      ajaxObject: {
        // add more ajax settings here
        // see http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings
        dataType: 'json',
        type: 'GET'
      },
      ajaxProcessing: function(data, table, xhr){
        // do something with the ajax data;
        return [ total_rows ];
      }
    });
});
Example
Function null This callback allows you to customize the error message displayed in the thead (v2.23.0; v2.23.1).

In v2.23.1
  • A settings parameter was added before the exception parameter to exactly match the parameters returned by the jQuery .ajaxError() method.
  • This function is now always called, even if the $.tablesorter.showError function is called by an external function with only a string.
Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_ajaxError

When there is an ajax error, the $.tablesorter.showError function is called. In v2.23.0, that function now checks this callback to allow adding a custom error message.

Use it as follows:
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      ajaxError: function( config, xhr, settings, exception ) {
        // returning false will abort the error message
        // the code below is the default behavior when this callback is set to `null`
        return
          xhr.status === 0 ? 'Not connected, verify Network' :
          xhr.status === 404 ? 'Requested page not found [404]' :
          xhr.status === 500 ? 'Internal Server Error [500]' :
          exception === 'parsererror' ? 'Requested JSON parse failed' :
          exception === 'timeout' ? 'Time out error' :
          exception === 'abort' ? 'Ajax Request aborted' :
          'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']' );
      }
    });
});
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).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_initialRows

Use this option as follows:

$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      processAjaxOnInit: false,
      initialRows: {
        total: 100,
        filtered: 100
      },
      // other ajax settings...
    });
});
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).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_processAjaxOnInit
Function null 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, v2.17.3).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_ajaxProcessing

This function was created and modified to allow you a great deal of flexibility. The only required information that this function needs to return is an array containing the total number of rows, which is needed to calculate total pages.

There are numerous examples below. Choosing which one to use is left to you. For more information, please check out related questions on Stackoverflow, in particular see this thread about how to use the different ajax options together.

In v2.10, the returned rows is now optional. And it can either be an array of arrays or a jQuery object (not attached to the table)

Process your ajax data so that the following information is returned:

Object

After tablesorter v2.17.3, this function can include a filteredRows property which will update the internal value and thus show a proper filtered row count, and update the "goto" page drop down selector appropriately.

After tablesorter v2.11, the ajaxProcessing function can return an object containing these properties, along with any extra properties. These extra properties will be available for use within the pager output string (see more details in issue #326);

So, lets say the data sent by the server looks like this:
{
    "total_rows"    : 100,
    "filtered_rows" : 75,
    "new_headers"   : [ "ID", "Name", "Data", "Value" ],
    "data"          : '<tr><td>a123</td><td>abc</td><td>xyz</td><td>999</td></tr>',
    "subject"       : "cheese",
    "tasty"         : "It's delicious!"
}
This ajaxProcessing function must return an object with "total", "headers" and "rows" properties! As before, "total" is the only required property; if the headers don't need to be changed, don't return a headers array, and if you append the rows to the table yourself within the ajaxProcessing function, you don't need to return a "rows" property.
ajaxProcessing: function(result, table, xhr){
    if (result && result.hasOwnProperty('data')) {

        // "total" is a required property!
        result.total = result["total_rows"];

        // "filteredRows" is optional - in tablesorter v2.17.3, this updates the filter row count internally
        // and updates the "goto" page dropdown selector appropriately
        result.filteredRows = result["filtered_rows"];

        // "headers" is optional. This is not needed if the table headers don't change
        result.headers = result["new_headers"];

        // "rows" is optional. No need to return this if you process and add the rows to the table yourself
        // otherwise, return an array of arrays or jQuery object (shown in this example)
        result.rows = $(result.data);

        return result;
    }
}
Now in the output string, you can also reference the extra ajax data:
output : '{startRow} to {endRow} of {filteredRows} ({totalRows}) rows about {subject} ({tasty})'

Array (total only)

After tablesorter v2.10, just build the table yourself and return the total number of rows:
ajaxProcessing: function(data, table, xhr){
  if (data && data.hasOwnProperty('rows')) {
    var r, row, c, d = data.rows,
    // total number of rows (required)
    total = data.total_rows,
    // all rows: array of arrays; each internal array has the table cell data for that row
    rows = '',
    // len should match pager set size (c.size)
    len = d.length;
    // this will depend on how the json is set up - see City0.json
    // rows
    for ( r=0; r < len; r++ ) {
      rows += '<tr class="ajax-row">'; // new row
      // cells
      for ( c in d[r] ) {
        if (typeof(c) === "string") {
          rows += '<td>' + d[r][c] + '</td>'; // add each table cell data to row
        }
      }
      rows += '</tr>'; // end new row
    }
    // find first sortable tbody, then add new rows
    table.config.$tbodies.eq(0).html(rows);
    // no need to trigger an update method, it's done internally
    return [ total ];
  }
}

Array (rows as jQuery object)

After tablesorter v2.10, return a jQuery object
ajaxProcessing: function(data, table, xhr){
  if (data && data.hasOwnProperty('rows')) {
    var r, row, c, d = data.rows,
    // total number of rows (required)
    total = data.total_rows,
    // array of header names (optional)
    headers = data.headers,
    // all rows: array of arrays; each internal array has the table cell data for that row
    rows = '',
    // len should match pager set size (c.size)
    len = d.length;
    // this will depend on how the json is set up - see City0.json
    // rows
    for ( r=0; r < len; r++ ) {
      rows += '<tr class="ajax-row">'; // new row
      // cells
      for ( c in d[r] ) {
        if (typeof(c) === "string") {
          rows += '<td>' + d[r][c] + '</td>'; // add each table cell data to row
        }
      }
      rows += '</tr>'; // end new row
    }
    // don't attach the $(rows) because it's difficult to tell old from new data
    // and no need to trigger an update method, it's done internally
    return [ total, $(rows), headers ];
  }
}
Or, if your JSON contains all the rows within a string this method will work:
ajaxProcessing: function(data, table, xhr){
  if (data && data.hasOwnProperty('rows')) {
    // data.rows would look something like this
    // '<tr><td>r0c0</td><td>r0c1</td></tr><tr><td>r1c0</td><td>r1c1</td></tr>'
    return [ data.total, $(data.rows), data.headers ];
  }
}

Array (rows as an array of arrays)

After tablesorter v2.1, this function must return an array with values in any of the following orders:
// [ total_rows (number), rows (array of arrays), headers (array; optional) ]
// or [ rows, total_rows, headers ]
// or [ total_rows, $(rows) ]
// or [ total_rows ]
[
  100, // total rows
  [
    [ "row1cell1", "row1cell2", ... "row1cellN" ],
    [ "row2cell1", "row2cell2", ... "row2cellN" ],
    ...
    [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
  ],
  [ "header1", "header2", ... "headerN" ] // optional
]
Note: In v2.14.3, the contents of the array can also contain table cell markup (i.e. "<td class='green'>+ 10%</td>").

Here is some example JSON (comments added, but not allowed in JSON) which is contained in the City0.json file:
{
  // total rows
  "total_rows": 80,
  // headers
  "cols" : [
    "ID", "Name", "Country Code", "District", "Population"
  ],
  // row data...
  "rows" : [{
    "ID": 1,
    "Name": "Kabul",
    "CountryCode": "AFG",
    "District": "Kabol",
    "Population": 1780000
  }, {
    // row 2, etc...
  }]
}
The above JSON is processed by the following code (this returns an array of array of table rows):
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      ajaxUrl: "http://mydatabase.com?page={page}&size={size}",
      ajaxProcessing: function(data, table, xhr){
        if (data && data.hasOwnProperty('rows')) {
          var r, row, c, d = data.rows,
          // total number of rows (required)
          total = data.total_rows,
          // array of header names (optional)
          headers = data.cols,
          // all rows: array of arrays; each internal array has the table cell data for that row
          rows = [],
          // len should match pager set size (c.size)
          len = d.length;
          // this will depend on how the json is set up - see City0.json
          // rows
          for ( r = 0; r < len; r++ ) {
            row = []; // new row array
            // cells
            for ( c in d[r] ) {
              if (typeof(c) === "string") {
                row.push(d[r][c]); // add each table cell data to row array
              }
            }
            rows.push(row); // add new row array to rows array
          }
          return [ total, rows, headers ]; // or return [ rows, total, headers ] in v2.9+
        }
      }
    });
});
Example
String "{page}/{totalPages}" 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).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_output

In v2.28.4

The output element can now include two data-attributes, data-pager-output and data-pager-output-filtered which override this setting string when set.

<span class="pagedisplay" data-pager-output="{startRow:input} – {endRow} / {totalRows} total rows" data-pager-output-filtered="{startRow:input} – {endRow} / {filteredRows} of {totalRows} total rows"></span>

It will not override this option if set as a function, or if a specific output is returned from the server through ajax.

In v2.27.7, this option can also be set as a function
output: function(table, pager) {
	return 'page ' + pager.startRow + ' - ' + pager.endRow;
}
This option replaced the original separator option, which only separated the page number from the total number of pages. The formatted output from this option is placed inside the information block targeted by the cssPageDisplay option.

Use it as follows:
$(function(){
  $("table")
    .tablesorter()
    .tablesorterPager({
      output: '{startRow} to {endRow} of {totalRows} rows'
    });
});
The following tags are replaced within the output string:
TagReplaced with
{size}The current pager size
{page}The current pager page
{page:input}The current pager page within an input (v2.17.6)
{totalPages}Total number of pager pages
{filteredPages}Total number of pages left after being filtered
{startRow}Starting row number currently displayed
{startRow:input}Starting row number currently displayed within an input (v2.17.6)
{endRow}Ending row number currently displayed
{filteredRows}Total number of rows left after being filtered
{totalRows}Total number of rows
1 2 3 4
Boolean true If true, the addon hides the left pager arrow on the first page and right pager arrow on the last page.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_updateArrows

If true the classname from the cssDisabled option is applied to the arrows when at either page extreme.
Example
Numeric 0 Set the starting page of the pager (zero-based index).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_startPage
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).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_pageReset
Numeric 10 Set initial number of visible rows. This value is changed by the dropdown selector targeted by the cssPageSize option.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_size
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).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_savePages
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)

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_storageKey
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).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_fixedHeight

This option replaced the original positionFixed and offset options which set the absolute position of the pager block.

If true, it should maintain the height of the table, even when viewing fewer than the set number of records (go to the last page of any demo to see this in action). It works by adding an empty row to make up the differences in height.
Example
Boolean false If true, child rows will be counted towards the pager set size (v2.13).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_countChildRows

*CAUTION* When true, child row(s) may not appear to be attached to its parent row, may be split across pages or may distort the table if rowspan or cellspans are included within the child row.

If this option is false, child row(s) will always appear on the same page as its parent.
Boolean false If true, rows are removed from the table to speed up the sort of large tables (v2.0.21).

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_removeRows

The original tablesorter plugin (v2.0.5) removed rows automatically, without providing an option. It really does speed up sorting of very large tables, but also breaks updating and modifying table content dynamically.

If this option is false, the addon only hides the non-visible rows; this is useful if you plan to add/remove rows with the pager enabled.
Example
String ".first" This option contains a jQuery selector string pointing to the go to first page arrow. See container for full HTML.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.first
Example
String ".prev" This option contains a jQuery selector string pointing to the go to previous page arrow. See container for full HTML.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.prev
Example
String ".next" This option contains a jQuery selector string pointing to the go to next page arrow. See container for full HTML.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.next
Example
String ".last" This option contains a jQuery selector string pointing to the go to last page arrow. See container for full HTML.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.last
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)

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.gotoPage (changed from goto in v2.17.3)

Please note that this select dropdown is initially empty and automatically updated by the plugin with the correct number of pages, which depends on the size setting.
Example
String ".pagedisplay" This option contains a jQuery selector string pointing to the output element (v2.0.9)

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.pageDisplay

In the original tablesorter (v2.0.5) this option could only target an input, it was updated (v2.0.9) to display the formatted output from the output option inside of any element (span, div or input).
Example
String ".pagesize" This option contains a jQuery selector string pointing to the page size selector. See container for full HTML.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_selectors.pageSize
Example
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.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_css.errorRow

Note there is no period "." in front of this class name (it is not a selector).
String "disabled" This option contains the class name that is applied to disabled pager controls.

Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_css.disabled

More explicitly, this class is applied to the pager arrows when they are at either extreme of pages and the updateArrows option is true. When the pager has been disabled, this class is applied to all controls.

Note there is no period "." in front of this class name (it is not a selector).
Removed Options
Boolean false Filter: This option was removed in v2.15... sorry for the sudden notice.

This option has been replaced by the filter_external option.

Show any rows that match a search query. If this option is true any column match will show that row; but there are limitations (v2.13.3).

It is best if this filter_anyMatch option is used with a single search input as follows:
<input class="search" type="search">
<button type="button" class="reset">Reset Search</button>
$(function(){
  $("table").tablesorter({
    widgets: ["filter"],
    widgetOptions : {
      filter_anyMatch : true,
      filter_columnFilters: false,
      filter_reset: '.reset'
    }
  });

  // Target the $('.search') input using built in functioning
  // this binds to the search using "search" and "keyup"
  // Allows using filter_liveSearch or delayed search &
  // pressing escape to cancel the search
  $.tablesorter.filter.bindSearch( $table, $('.search') );

});
String "jui" UiTheme: This option was removed in v2.19.0! It has been replaced by theme.

This option contains the name of the theme. Currently jQuery UI ("jui") and Bootstrap ("bootstrap") themes are supported (updated v2.4)

* NOTE * only the uitheme widget option was removed. All of the information below is still pertinent and portions have been copied to the core theme option.

To modify the class names used, extend from the $.tablesorter.themes variable as follows:

// Extend the themes to change any of the default class names ** NEW **
$.extend($.tablesorter.themes.jui, {
  // change default jQuery uitheme icons - find the full list of icons
  // here: http://jqueryui.com/themeroller/ (hover over them for their name)
  table        : 'ui-widget ui-widget-content ui-corner-all', // table classes
  caption      : 'ui-widget-content',
  // header class names
  header       : 'ui-widget-header ui-corner-all ui-state-default', // header classes
  sortNone     : '',
  sortAsc      : '',
  sortDesc     : '',
  active       : 'ui-state-active', // applied when column is sorted
  hover        : 'ui-state-hover',  // hover class
  // icon class names
  icons        : 'ui-icon', // icon class added to the <i> in the header
  iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // "caret" class renamed in jQuery v1.12.0
  iconSortAsc  : 'ui-icon-carat-1-n ui-icon-caret-1-n',
  iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s',
  // other
  filterRow    : '',
  footerRow    : '',
  footerCells  : '',
  even         : 'ui-widget-content', // even row zebra striping
  odd          : 'ui-state-default'   // odd row zebra striping
});
This widget option replaces the previous widgetUitheme. All theme css names are now contained within the $.tablesorter.themes variable. Extend the default theme as seen above.

The class names from the $.tablesorter.themes.{name} variable are applied to the table as indicated.

As before the jQuery UI theme applies the default class names of "ui-icon-arrowthick-2-n-s" for the unsorted column, "ui-icon-arrowthick-1-s" for the descending sort and "ui-icon-arrowthick-1-n" for the ascending sort. (Modified v2.1; Updated in v2.4). Find more jQuery UI class names by hovering over the Framework icons on this page: http://jqueryui.com/themeroller/

Use the "uitheme" option to change the css class name as follows:
$(function(){
  $("table").tablesorter({
    theme     : 'jui',       // set theme name from $.tablesorter.themes here
    widgets   : ["uitheme"], // initialize ui theme styling widget of the table
    widgetOptions: {
      uitheme : "jui"        // this is now optional in v2.7, it is overridden by the theme option
    }
  });
});
To add a new theme, define it as follows; replace "custom" with the name of your theme:
$.tablesorter.themes.custom = {
  table      : 'table',       // table classes
  header     : 'header',      // header classes
  footerRow  : '',
  footerCells: '',
  icons      : 'icon',        // icon class added to the <i> in the header
  sortNone   : 'sort-none',   // unsorted header
  sortAsc    : 'sort-asc',    // ascending sorted header
  sortDesc   : 'sort-desc',   // descending sorted header
  active     : 'sort-active', // applied when column is sorted
  hover      : 'hover',       // hover class
  filterRow  : 'filters',     // class added to the filter row
  even       : 'even',        // even row zebra striping
  odd        : 'odd'          // odd row zebra striping
}
Example
Numeric 0 Pager: This option was removed!

The original tablesorter pager plugin absolutely positioned the pager controls at the bottom of the table. It appears that this option was intended to tweak the position of the pager container. The option exists, but no code was found.
Boolean true Pager: This option was removed!

If this option were true, the original tablesorter pager plugin would absolutely position the pager controls at the bottom of the table.
String "/" Pager: This option was removed! Use the output option to allow for more control over the formatting.

The original tablesorter pager plugin would combine the current page with the calculated total number of pages within the cssPageDisplay with this separator string inbetween.

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).

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
  $rows = $( 'tr.addedRows' ), // jQuery selector of newly appended row(s)
  // applies or reapplies a sort to the table; use false to not update the sort
  resort = true, // or [ [0,0], [1,0] ] etc
  callback = function( table ) {
    // do something
  };
$.tablesorter.addRows( config, $rows, resort, callback );

Triggered event method:

It does not work the same as "update" in that it only adds rows, it does not remove them.

Also, use this method to add table rows while using the pager plugin. If the "update" method is used, only the visible table rows continue to exist.
// Add multiple rows to the table
var row = '<tr><td>Inigo</td><td>Montoya</td><td>34</td>' +
  '<td>$19.99</td><td>15%</td><td>Sep 25, 1987 12:00PM</td></tr>',
  $row = $( row ),
  // resort table using true to reapply the current sort; set to false to prevent resort
  // if undefined, the resort value will be obtained from config.resort (added v2.19.0)
  // As of v2.19.0, the resort variable can contain a new sortList to be applied
  // A callback method was added in 2.3.9.
  resort = true, // or [ [0,0], [1,0] ] etc
  callback = function( table ){
    alert( 'rows have been added!' );
  };
$( 'table' )
  .find( 'tbody' ).append( $row )
  .trigger( 'addRows', [ $row, resort, callback ] );

  • In v2.23.0,
    • If a table contains only one tbody (not counting information only tbodies; which have a class name from cssInfoBlock), then a row string can be used in this method.
      var $table = $( 'table' ),
      config = $table[ 0 ].config;
      // triggered event method
      $table.trigger( 'addRows', [ '<tr>...</tr>', true ] );
      
      // direct method
      $.tablesorter.addRows( config, '<tr>...</tr>', true );
    • So instead of making a jQuery object, appending it to the table, then passing the reference to the method, you can just pass a string. This method doesn't work if a table has multiple tbodies, because the plugin doesn't know where you want to add the rows.
  • In v2.16.1, the $row parameter can be a row DOM element or jQuery object.
Example
Use this method reset the table to it's original settings. (v2.17.0).
Using this method will clear out any settings that have changed since the table was initialized (refreshes the entire table); so any sorting or modified widget options will be cleared.
However, it will not clear any values that were saved to storage. This method is basically like reloading the page.
$('table').trigger('resetToLoadState');
Use this method to initialize a sort while targeting a specific column header (v2.9).
// Target a specific header
$('table').find('th:eq(2)').trigger('sort');
Using this method will maintain the sorting order; so, if the column is already sorted in ascending order, this method will act as if you manually clicked on the header. Whatever sort order is applied is dependent on other option settings such as initialSortOrder, lockedOrder (set within the headers), sortReset option, sortRestart and will be ignored if the column sort is disabled (sorter: false).
Use this method to sort an initialized table in the desired order (v2.23.0)

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
	sort = [ [ 0,0 ], [ 1,0 ] ],
	callback = function( table ) {
		// do something
	};
	// NOTE: the triggered 'sorton' method requires the sort & callback methods to be
	// passed inside an array, this direct method does not.
	// Also, notice the "O" of "sortOn" is capitalized in this direct method
$.tablesorter.sortOn( config, sort, callback );

Triggered event method:

// Choose a new sort order
var sort = [ [0,0], [2,0] ],
    callback = function( table ){
        alert( 'new sort applied to ' + table.id );
    };
// Note that the sort value below is inside of another array (inside another set of square brackets)
// without a callback it could look like this:
$( 'table' ).trigger( 'sorton', [ [[0,0],[2,0]] ] );

// when including a callback method the outer square bracket wrap both parameters (added in 2.3.9).
$( 'table' ).trigger( 'sorton', [ sort, callback ] );
*NOTE* using this method to sort ignores the additions from the sortForce and sortAppend options.

In v2.17.0, the sort direction can be set using "a" (ascending), "d" (descending), "n" (next), "s" (same) & "o" (opposite).
$('table').trigger('sorton', [ [[0,"a"],[2,"n"]] ]);
Please try out the demo (example link) to better understand how these values work.
Example
Use this method to reset the table to it's initial unsorted state (v2.4.7; v2.23.0).

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
	callback = function( table ) {
		// do something
	};
$.tablesorter.sortReset( config, callback );

Triggered event method:

This method immediately resets the entire table sort, while the option only resets the column sort after a third click.

In v2.16.0, a callback function was added to this method.

// Reset the table (make it unsorted)
var callback = function( table ) {
	console.log( 'sort has been reset' );
};
$( 'table' ).trigger( 'sortReset', [ callback ] );
*NOTE* Don't confuse this method with the sortReset option.
Example
/ Update the tbody's stored data (update & updateRows do exactly the same thing; v2.23.0)

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
	// applies or reapplies a sort to the table; use false to not update the sort
	resort = true, // or [ [0,0], [1,0] ] etc
	callback = function( table ) {
		// do something
	};
$.tablesorter.update( config, resort, callback );

Triggered event method:

// Add new content
$( 'table tbody' ).append( html );

// let the plugin know that we made a update
// the resort flag set to true will trigger an automatic resort using the current sort
// if set to false, no new sort will be applied; or set it to any sortList value (e.g. [[0,0]]; new v2.19.0)
// A callback method was added in 2.3.9.
var resort = true,
    callback = function( table ){
        alert( 'new sort applied' );
    };
$( 'table' ).trigger( 'update', [ resort, callback ] );

// As of version 2.19.0, if the resort parameter is undefined, the setting from the config.resort will be used

// As of version 2.0.14, the table will automatically resort after the update (if the "resort" flag is true
// & will use the current sort selection), so include the following if you want to specify a different sort

// set sorting column and direction, this will sort on the first and third column
var sorting = [ [2,1], [0,0] ];
// method to use prior to v2.19.0
// $( 'table' )
//  .trigger( 'update', [ false ] )
//  .trigger( 'sorton', [ sorting ] );
// After v2.19.0; do the following to apply a new sort after updating
// if sorting is an empty array [], then the sort will be reset
$( 'table' ).trigger( 'update', [ sorting ] );
NOTE Don't confuse this method with the sortReset option. updateRows was added to work around the issue of using jQuery with the Prototype library. Triggering an "update" would make Prototype clear the tbody; Please see issue #217 for more details.
Example
Update a column of cells (thead and tbody) (v2.8; v2.23.0).

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
	// applies or reapplies a sort to the table; use false to not update the sort
	resort = true, // or [ [0,0], [1,0] ] etc
	callback = function( table ) {
		// do something
	};
$.tablesorter.updateAll( config, resort, callback );

Triggered event method:

// Change thead & tbody column of cells
// remember, "eq()" is zero based & "nth-child()" is 1 based
$("table thead th:eq(2)").html("Number");
// add some random numbers to the table cell
$("table tbody").find('td:nth-child(3)').html(function(i,h){
  return Math.floor(Math.random()*10) + 1; // random number from 0 to 10
});

// reapply the current sort if resort = true
// do not reapply the current sort if resort = false
// if undefined, resort will be obtained from config.resort (added v2.19.0)
// as of v2.19.0, apply a new sort if resort = [[0,0]] (or whatever)
// or the sort is reset if resort = []
var resort = true,
  // add a callback, as desired
  callback = function(table){
    alert('table updated!');
  };

// let the plugin know that we made a update, then the plugin will
// automatically sort the table based on the header settings
$("table").trigger("updateAll", [ resort, callback ]);
Example
Update the parsers, only if not defined, then update the internal cache (v2.15.4; v2.27.0).

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
	// optional parameter to target tbodies
	$tbodies = $( 'table' ).children( 'tbody.totals' ),
	callback = function( table ) {
		// do something
	};
$.tablesorter.updateCache( config, callback, $tbodies );

Triggered event method:

*NOTE* In v2.22.2, a new parameter was added to allow passing a jQuery object containing tbodies to be added to the table (for the tbody sorting widget).

This method is used by the pager (addon & widget) to update the data stored within the cache after the content has been updated using ajax.

// optional callback function
var callback = function( table ){ /* do something */ },
	// optional in v2.22.2; defaults to table.config.$tbodies if undefined
	$tbodies = $( 'table' ).children( 'tbody' );
$("table").trigger("updateCache", [ callback, $tbodies ] );
Example
Adds all of the cached table rows back into the table (v2.23.0).

This method was originally designed to be used with the pager. It should be used under these conditions:
  • When the pager removeRows option is true.
  • When not using the "updateCell" or "addRows" methods.
  • Before manually adding or removing table rows.
  • And, before triggering an "update".
Note: The entire table is stored in the cache, but when using the pager with the removeRows option set to true, only the visible portion is actually exists within the table. So, use this option to add all stored rows back into the table before manually changing the contents. Otherwise, if any update method is triggered, only the visible rows will be added back to the cache.

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config;
// there is no callback available when using this direct method because
// it may divert to pager injected functions, if the pager is being used
$.tablesorter.appendCache( config );

Triggered event method:

// how to update the table contents
$("table")
  .trigger("appendCache")
  .append('<tr>...</tr>') // add new row(s), or delete rows
  .trigger("update"); // update the cache
Refresh table headers only (v2.23.0).

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
	callback = function( table ) {
		// do something
	};
$.tablesorter.updateHeaders( config, callback );

Triggered event method:

$(function() {
  $( 'table' ).tablesorter();

  // click on a button somewhere on the page to update header index
  $( 'button' ).click( function() {
    // Do something after the cell update in this callback function
    var $headerCell = $('thead th:eq(1)'),
      index = $headerCell.data( 'counter' ) || 0,
      callback = function( table ) {
          /* do something */
        };

    // change header text
    $headerCell
      .html( 'header click #' + index )
      // update header data
      .data( 'counter', index++ );

    // update the header, includes rebinding events & using the header template
    $( 'table' ).trigger( 'updateHeaders', callback );
    return false;
  });
});
Update a table cell in the tablesorter data (v2.23.0).

Direct method:

In v2.23.0, this method can be called directly as follows:

var config = $( 'table' )[ 0 ].config,
	$cell = $( 'td.random' ), // jQuery selector or DOM element of newly updated cell
	// applies or reapplies a sort to the table; use false to not update the sort
	resort = true, // or [ [0,0], [1,0] ] etc
	callback = function( table ) {
		// do something
	};
$.tablesorter.updateCell( config, $cell, resort, callback );

Triggered event method:

$(function() {
  $( 'table' ).tablesorter();

  $( 'td.discount' ).click( function() {

    // Do we want to reapply the current sort on the column?
    // see updateRow for other resort settings as of v2.19.0
    // if resort is undefined, the value from config.resort (added v2.19.0) will be used
    var resort = false,
        // Do something after the cell update in this callback function
        callback = function( table ) {
          /* do something */
        },
        // randomize a number & add it to the cell
        discount = '$' + Math.round( Math.random() * Math.random() * 100 ) + '.' +
          ( '0' + Math.round( Math.random() * Math.random() * 100 ) ).slice( -2 );

    // add new table cell text
    $( this ).text( discount );

    // update the table, so the tablesorter plugin can update its value
    // set resort flag to false to prevent automatic resort (since we're using a different sort below)
    // prior to v2.19.0, leave the resort flag as undefined, or with any other value, to automatically resort the table
    // new resort values can be set as of v2.19.0 - please see the "updateRow" documentation for more details
    // $( 'table' ).trigger( 'updateCell', [ this ] ); < - resort is undefined so the table WILL resort
    $( 'table' ).trigger( 'updateCell', [ this, resort, callback ] );

    // As of version 2.0.14, the table will automatically resort (using the current sort selection)
    // after the update, so include the following if you want to specify a different sort

    // prior to v2.19.0, set sorting column and direction, this will sort on the first and third column
    // after v2.19.0, add any new sort to the "resort" variable above
    var sorting = [ [ 3,1 ] ];
    $( 'table' ).trigger( 'sorton', [ sorting ] );

    return false;
  });
});
Example
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).

In v2.25.4, the direct method will now correctly accept $('table'). Previously, only $('table')[0] would work.

In v2.25.0, this method ensures that the widget initialization code is executed as well as the format function. So now a widget that was not previously initialized or had been previously removed, can be reapplied.

Only one widget can be applied at a time using this method.

Direct method:

$.tablesorter.applyWidgetId( $('table'), 'zebra' );

Triggered event method:

$(function(){
  // initialize tablesorter without the widget
  $('table').tablesorter();

  // click a button to apply the zebra striping
  $('button').click(function(){
    $('table').trigger('applyWidgetId', 'zebra');
    return false;
  });

});
Example
Apply the set widgets to the table (v2.16.0).

This method only updates the widgets listed in the table.config.widgets option.

// This method applies the widgets already added to tablesorter
$('table').trigger('applyWidgets');
Use this method can be used to add multiple widgets to the table.
var $table = $( 'table' );
$table[0].config.widgets = [ 'zebra', 'columns' ];
$table.trigger('applyWidgets');
Example
Remove the named widget from the table (v2.25.0).

This method will remove the named widget(s) from the table.

Direct method:

$.tablesorter.removeWidget( $( 'table' ), widget );

Triggered event method:

$( 'table' ).trigger( 'removeWidget', widget );

The widget parameter can be used as follows:

  • Single widget name - string
    // only remove zebra widget
    $( 'table' ).trigger( 'removeWidget', 'zebra' );
  • Multiple widgets names - array or string (space or comma separated)
    // remove multiple widgets (the below methods are all equivalent)
    $( 'table' ).trigger( 'removeWidget', 'zebra columns' );
    $( 'table' ).trigger( 'removeWidget', 'zebra, columns' );
    $( 'table' ).trigger( 'removeWidget', [ 'zebra', 'columns' ] );
  • true - boolean (removes all widgets; passing false does nothing)
    // remove all widgets
    $( 'table' ).trigger( 'removeWidget', true );
Example
Use this method to remove tablesorter from the table (v2.3.2; v2.16).
// Remove tablesorter and all classes
$("table").trigger("destroy");

// Remove tablesorter and all classes but the "tablesorter" class on the table
// callback is a function
$("table").trigger("destroy", [false, callback]);
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).

Trigger this method using either of the following methods (they are equivalent):
// trigger a refresh widget event
$('table').trigger('refreshWidgets', [doAll, dontapply]);

// Use the API directly
$.tablesorter.refreshWidgets(table, doAll, dontapply)
  • If doAll is true it removes all widgets from the table. If false only non-current widgets (from the widgets option) are removed.
  • When done removing widgets, the widget re-initializes the currently selected widgets, unless the dontapply parameter is true leaving the table widget-less.
  • Note that if the widgets option has any named widgets, they will be re-applied to the table when it gets resorted. So if you want to completely remove all widgets from the table, also clear out the widgets option $('table')[0].config.widgets = [];
Example
Widget Methods
filter: Trigger the filter widget to reset the search criteria (v2.7.7).

If you are using the filter_formatter option to add custom input elements, this function may not work on those columns. Please refer to the filter_formatter section for more details.
$(function(){
  // this is the same code that the "filter_reset" element runs to clear out the filters.
  $('button').click(function(){
    $('table').trigger('filterReset');
    return false;
});
This method is used by the filter_reset option when defined.
Example
filter: Trigger the filter widget to reset the sort & reset the search criteria (v2.28.7).

This combination reset was added to prevent issues with the widgets not being updated after a combination of filterReset and sortReset due to internal timers preventing multiple widget applications in a row.

This method does not include a callback parameter similiar to the sortReset method.
$(function() {
  $('button').click(function(){
    $('table').trigger('filterAndSortReset');
    return false;
});
filter: Make the filter widget reset any saved searches (v2.25.6).

Use this as follows:
$(function(){
  // this is the same code that the "filter_reset" element runs to clear out the filters.
  $('button').click(function(){
    $('#myTable').trigger('filterResetSaved');
    return false;
});
This is the equivalent of executing this function:
// clear the current table stored filters
$.tablesorter.storage( $('#myTable'), 'tablesorter-filters', '' );
Example
Trigger the saveSort widget to clear any saved sorts for that specific table (v2.7.11).
$(function(){
  $('button').click(function(){
    $('table').trigger('saveSortReset');
    return false;
  });
});
Pager Methods
Trigger the pager to change the page size (v2.7.4; v2.24.0).
$(function(){
  $('table').trigger('pageSize', 15);
});
In v2.24.0, this option will now accept "all" as a setting, and in turn display all rows.
Trigger the pager to change the current page (v2.7.7).

If no value is passed, the pager will reset to page 1; otherwise, pass a "one-based" index of the desired page
$(function(){
  $('table').trigger('pageSet', 3); // pass a one-based index
});
Trigger the pager to change the current page & size (v2.19.0; ; v2.24.0).

If no value is passed, the pager will reset to page 1 with the original pager size setting; otherwise, pass a "one-based" index of the desired page and the pager size as an array
$(function(){
  $('table').trigger('pageAndSize', [ 2, 20 ]); // pass a one-based page index & page size
});
In v2.24.0, this option will now accept "all" as a page size setting, and in turn display all rows; the page number will be force to page one.
Force the pager to update the table with the current settings (v2.19.0).

If there is a need, this method will force the (ajax and non-ajax) pager to update. Use it as follows:
$(function(){
  $('table').trigger('pagerUpdate');
});
Or, if you need, you can optionally pass a new page number:
$(function(){
  $('table').trigger('pagerUpdate', 3); // update and set to page 3
});
Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16; v2.23.0).

In v2.23.0, this method was changed from destroy.pager to destroyPager because of issues with unique namespacing.

$(function(){
  $('table').trigger('destroyPager');
});
The only way to restore the pager addon is to re-initialize the pager addon:
$(function(){
  $('table').tablesorterPager(pagerOptions);
});
Example
This method will put the pager into a disabled state (v2.0.21.2; v2.23.0).

In v2.23.0, this method was changed from disable.pager to disablePager because of issues with unique namespacing.

The disabled state will reveal all table rows and disable, but not hide, pager controls.
$(function(){
  $('table').trigger('disablePager');
});
Example
This method will re-enable the pager, but only from the disabled state (v2.0.21.2; v2.23.0).

In v2.23.0, this method was changed from enable.pager to enablePager because of issues with unique namespacing.

$(function(){
  $('table').trigger('enablePager');
});
Example

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 when tablesorter has completed initialization. (v2.2).
$(function(){

  // bind to initialized event BEFORE initializing tablesorter*
  $("table")
    .bind("tablesorter-initialized",function(e, table) {
      // do something after tablesorter has initialized
    });

  // initialize the tablesorter plugin
  $("table").tablesorter({
    // this is equivalent to the above bind method
    initialized : function(table){
      // do something after tablesorter has initialized
    }
  });

});
* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs.
This event fires immediately before tablesorter begins resorting the table.
$(function(){

  // initialize the tablesorter plugin
  $("table").tablesorter();

  // bind to sort events
  $("table").bind("sortBegin",function(e, table) {
    // do something crazy!
  });
});
This event fires immediately after the tablesorter header has been clicked, initializing a resort.
$(function(){

  // initialize the tablesorter plugin
  $("table").tablesorter();

  // bind to sort events
  $("table")
    .bind("sortStart",function(e, table) {
      $("#overlay").show();
    })
    .bind("sortEnd",function(e, table) {
      $("#overlay").hide();
    });
});
Example
This event fires when tablesorter has completed resorting the table.
$(function(){

  // initialize the tablesorter plugin
  $("table").tablesorter();

  // bind to sort events
  $("table")
    .bind("sortStart",function(e, table) {
      $("#overlay").show();
    })
    .bind("sortEnd",function(e, table) {
      $("#overlay").hide();
    });
});
Example
This event fires after tablesorter has completed updating (v2.3.9).
This occurs after an "update", "updateAll", "updateCell" or "addRows" method was called, but before any callback functions are executed.
$(function(){

  // initialize the tablesorter plugin
  $('table')
    .tablesorter()
    // bind to sort events

    .bind('updateComplete', function(e, table) {
      // do something after the table has been altered;
    });

});
This event fires after tablesorter has complete applying all widgets and is ready for its next action (v2.24.0).
This event occurs after an "updateComplete" and "pagerComplete" event. There may be some other table interaction if a widget includes any setTimeout functions.
$(function(){

  // initialize the tablesorter plugin
  $('table')
    .tablesorter()
    // bind to sort events

    .bind('tablesorter-ready', function(e, table) {
      // do something after tablesorter has finished interacting with the table;
    });

});
This event fires after tablesorter has completed executing the refreshWidget method (v2.19.0)

Use it as follows:
$(function(){

  // initialize the tablesorter plugin
  $('table')
    .tablesorter()
    // bind to sort events
    .bind('refreshComplete', function(e, table) {
      // do something after the 'refreshWidgets' has refreshed
    });

});
Widget Events
Event triggered when the filter widget has finished initializing (v2.4).

You can use this event to modify the filter elements (row, inputs and/or selects) as desired. Use it as follows:
$(function(){
  $('table')

    // bind to filter initialized event BEFORE initializing tablesorter*
    .bind('filterInit', function(event, config){
      $(this).find('tr.tablesorter-filter-row').addClass('fred');
    })

     // initialize the sorter
    .tablesorter({
      widgets : ['filter']
    });

});
* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs.
Example
Event triggered when the filter widget has started processing the search (v2.4).

You can use this event to do something like add a class to the filter row. Use it as follows:
$(function(){
  $('table').bind('filterStart', function(event, filters) {
    // filters contains an array of the current filters
    $(this).find('tr.tablesorter-filter-row').addClass('filtering');
  });
});
Example
Event triggered when the filter widget has finished processing the search (v2.4).

You can use this event to do something like remove the class added to the filter row when the filtering started. Use it as follows:
$(function(){
  $('table').bind('filterEnd', function(event, config){
    $(this).find('tr.tablesorter-filter-row').removeClass('filtering');
  });
});
Example
Event triggered when the stickyHeader widget has finished initializing (v2.10.4).

You can use this event to do something like modify content within the sticky header:
$(function(){
  $('table')
    // bind to the init event BEFORE initializing tablesorter*
    .bind('stickyHeadersInit', function(){
      // this.config.widgetOptions.$sticky contains the entire sticky header table
      this.config.widgetOptions.$sticky.find('tr.tablesorter-headerRow').addClass('sticky-styling');
    })

  // initialize the tablesorter plugin
  .tablesorter({
    widgets : ['stickyHeaders']
  });

});
* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs.
Pager Events
This event fires when the pager plugin begins to render the table on the currently selected page. (v2.0.7).
$(function(){

  // initialize the sorter
  $("table")
    .tablesorter()

    // initialize the pager plugin
    .tablesorterPager({
      container: $("#pager")
    })

    // bind to pager events
    .bind('pagerChange pagerComplete', function(event, options){
      // options = table.config.pager (pager addon)
      // options = table.config (pager widget) - so use options.pager.page below
      // c.totalPages contains the total number of pages
      $('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
    });

});
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).

Note In v2.18.1, the "pagerComplete" event also fires off immediately after pager initialization.

$(function(){

  // initialize the sorter
  $("table")
    .tablesorter()

    // initialize the pager plugin
    .tablesorterPager({
      container: $("#pager")
    })

    // bind to pager events
    .bind('pagerChange pagerComplete', function(event, options){
      // options = table.config.pager (pager addon)
      // options = table.config (pager widget) - so use options.pager.page below
      // c.totalPages contains the total number of pages
      $('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
    });

});
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).
$(function(){

  $("table")

    // bind to pager initialized event BEFORE calling the ADDON
    // or BEFORE initializing tablesorter when using the pager WIDGET*
    .bind('pagerBeforeInitialized', function(event, options){
      // options = table.config.pager (pager addon)
      // options = table.config (pager widget)

      // event = event object; options = pager options
    })

    // initialize the sorter
    .tablesorter()

    // initialize the pager plugin
    .tablesorterPager({
      container: $("#pager")
    });

});
* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs.
This event fires when the pager plugin has completed initialization (v2.4.4).
$(function(){

  $("table")

    // bind to pager initialized event BEFORE calling the ADDON
    // or BEFORE initializing tablesorter when using the pager WIDGET*
    .bind('pagerInitialized', function(event, options){
      // options = table.config.pager (pager addon)
      // options = table.config (pager widget) - so use options.pager.page below
      // c.totalPages contains the total number of pages
      $('#display').html( e.type + " event triggered, now on page " + (options.page + 1) );
    })

    // initialize the sorter
    .tablesorter()

    // initialize the pager plugin
    .tablesorterPager({
      container: $("#pager")
    });

});
* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs.
Example
This event fires when the pager plugin begins to change to the selected page (v2.4.4).
This event may fire before the pagerComplete event when ajax processing is involved, or after the pagerComplete on normal use. See issue #153.
$(function(){

  // initialize the sorter
  $("table")
    .tablesorter()

    // initialize the pager plugin
    .tablesorterPager({
      container: $("#pager")
    })

    // bind to pager events
    .bind('pageMoved', function(event, options){
      // options = table.config.pager (pager addon)
      // options = table.config (pager widget) - so use options.pager.page below
      // c.totalPages contains the total number of pages
      $('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
    });

});
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.

Changing a defaults will cause all tables using the code to alter its default behavior without needing to include the options while initializing. For example, changing the default theme will cause all tables to use the new theme (make sure to include the css!).

Note: If you wish to modify this object, make sure to either target the setting directly:
// set the default directly
$.tablesorter.defaults.theme = 'myCustomTheme';
Or use jQuery extend (include true parameter for more depth):
// Extend the object. Use `true` for more than one level of depth
$.extend( true, $.tablesorter.defaults, {
  theme: 'myCustomTheme',
  widgets: ['zebra', 'filter'],
  widgetOptions: {
    filter_placeholder: {
      search: 'Find in column...',
      select: 'Choose an option'
    },
    zebra: [ 'row-even', 'row-odd' ]
  }
});
If you don't use one of the above methods, the other default settings will be removed and cause unexpected issues.
Array This is an array of all parser objects added using the addParser function.

If a specific parser needs to be retreived from this array, use the getParserById 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.

If a specific widget needs to be retreived from this array, use the getWidgetById function.
Object This object contains the phrases (in English by default) added to the aria-label on each header column (v2.24.4).

In v2.24.4, sortDisabled was added to the language settings. It is added to disabled columns which may have a sort applied; so, instead of "nextAsc", "nextDesc" or "nextNone" being appended to the sort message, the "sortDisabled" content is added.

This is how the object is set up:
$.tablesorter.language = {
  sortAsc      : 'Ascending sort applied, ',
  sortDesc     : 'Descending sort applied, ',
  sortNone     : 'No sort applied, ',
  sortDisabled : 'sorting is disabled', // added v2.24.4
  nextAsc      : 'activate to apply an ascending sort',
  nextDesc     : 'activate to apply a descending sort',
  nextNone     : 'activate to remove the sort'
};
So, as an example, in the following situation:
  • A table header is named "Account #"
  • This column has an ascending sort applied
  • The next click on the header will be a descending sort, which means:
    • sortInitialOrder option has its default setting; so the sort order will switch from ascending to descending on the second click.
    • No lockedOrder is set within the headers option
Then the label will be built as follows:
// "Header Name" + $.tablesorter.language.sortAsc + $.tablesorter.language.nextDesc
"Account #: Ascending sort applied, activate to apply a descending sort"
If the next click were to reset the sort (sortReset applied), then the message would use $.tablesorter.language.nextNone.

In v2.24.4, if sorting is disabled but the column has a sort applied, the label will be built as follows:
// "Header Name" + $.tablesorter.language.sortDesc + $.tablesorter.language.sortDisabled
"Account #: Descending sort applied, sorting is disabled"
Use this variable to change the language as follows:
$(function(){

  $.tablesorter.language = {
    sortAsc      : 'sorting from a to z, ',
    sortDesc     : 'sorting from z to a, ',
    sortNone     : 'not sorted, but ',
    sortDisabled : 'sorting is disabled',
    nextAsc      : 'click to sort from a to z',
    nextDesc     : 'click to sort from z to a',
    nextNone     : 'click to clear the sort'
  }
  $('table').tablesorter();
});
1 2
Object This variable contains all instance methods of the config object. Added using addInstanceMethods function before table initialization (v2.21.0).

$.tablesorter.addInstanceMethods({
  columnSum: function(colNumber) {
    var sum = 0, tbodyIndex, normalizedRows, rowIndex;
    // `this` refers to config object
    for (tbodyIndex = 0; tbodyIndex < this.$tbodies.length; ++tbodyIndex) {
      normalizedRows = this.cache[tbodyIndex].normalized;
      for (rowIndex = 0; rowIndex < normalizedRows.length; ++rowIndex) {
        sum += normalizedRows[rowIndex][colNumber];
      }
    }
    return sum;
  },
  columnMean: function(colNumber) {
    return this.columnSum(colNumber) / this.totalRows;
  },
});

$('table').tablesorter();
c = $('table')[0].config;
console.log('sum of third column: ' + c.columnSum(2));
console.log('mean of third column: ' + c.columnMean(2));
Access the table configuration variables (config) using any of these methods:

// pure js, get the first table (zero index)
var config = document.getElementsByTagName('table')[0].config;
// or by table ID
var config = document.getElementById('mytable').config;

// using jQuery, get first table (zero index)
var config = $('table')[0].config;
// or from the jQuery data
var config = $('#mytable').data('tablesorter');
Object Internal list of table contents (v2.0.18; v2.20.0 )

This object contains the following:
  • tbody index (non-info block only, indexing now matches the config.$tbodies variable; v2.20.0)
    • colMax
      • This contains an array of the absolute value maximum numerical value for each "numerically" parsed column per tbody.
      • Text columns will have an undefined value in this array.
      • Used when determining how to sort text within a numeric column.
      • Access it as follows:
        // $('table')[0].config.cache[tbodyIndex].colMax[column];
        // try this in the console for this page:
        $('.tablesorter')[0].config.cache[0].colMax;
        // result: [undefined × 3, 45, 153.19, 44.7, 100.9, 1169133120000]
    • normalized
      • This contains an array of indexed table rows.
      • Within each row is an array of extracted, then parsed table contents for each column (plus one extra value; see the next comment).
      • It is important to note that the last value in the column array is the original row index value. This is used when resetting a column sort to its original unsorted order.
      • In v2.19.1, the raw unparsed data was added to the row data.
      • In v2.16.0, the last value in the column array is now an object which contains a jquery object of the row, index of the original unsorted order and a child array which contains raw html from any associated child row
        // $('table')[0].config.cache[tbodyIndex].normalized[row][column]
        // try this in the console for this page:
        $('.tablesorter')[0].config.cache[0].normalized[0];
        /* result: ["a1", "bruce", "almighty", 45, 153.19, 44.7, 77, 979830720000, {
            $row  : jQuery.fn.jQuery.init[1], // row (jQuery object)
            child : [], // child row raw html, if any
            // raw unparsed data from the table cells - added v2.19.1
            raw   : ["A1", "Bruce", "Almighty", "45", "$153.19", "44.7%", "+77", "Jan 18, 2001 9:12 AM"],
            order : 3   // original row index (unsorted)
        }]
        */
        to specifically target the extra row data, use this method:
        var config = $('.tablesorter')[0].config,
            dataIndex = config.columns, // number of columns within the table
            rowData = config.cache[tbodyIndex].normalized[row][ dataIndex ];
      • Note that all text values will be in lower case if the ignoreCase option is true.
      • This internal normalized content is what is actually sorted for maximum performance.
    • row (removed in v2.16.0)
      • Well not removed, but moved into the row data, within the normalized section of the cache as described above.
      • This contains an array of jQuery row objects.
      • These rows are never in sort order, and are used when updating the table after sorting the normalized content. The indexing of these rows is cross-referenced within the normalized values - the extra column value within the row array. Hopefully that makes sense.
The table.config.cache variable is useful when writing widgets that need access to the parsed content.
Numeric Internal count of the number of table columns in the header (v2.12)

This number is stored as a length (one-based), and takes into account any colspan and rowspan within the table head.

Note that the table.config.columns variable does not always correlate with the indexing of the headers stored within table.config.$headers because of multiple rows and column or row spans.
Array Internal list of each header's starting HTML (as text) (v2.8)

This HTML snapshot is taken using the $headers jQuery object, and done before the headerTemplate is applied and before the onRenderTemplate and onRenderHeader callbacks are executed.

This list is used by the $.tablesorter.restoreHeaders function to restore the table headers when the destroy method is executed.
Array Internal list of each header element as selected using jQuery selectors in the selectorHeaders option.

This list contains DOM elements (not jQuery objects of each table header cell like the $headers variable) and is how the original version of tablesorter stored these objects.
It is not used in the current version of tablesorter, and is only left in place for backwards compatibility with widgets written for the original tablesorter plugin.
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)

parser: falsedisable parsing for this column (this also disables sorting & filtering for the column; v2.17.6).
sorter: falsedisable sort for this column.
sorter: "text"Sort alpha-numerically.
sorter: "digit"Sort numerically.
sorter: "currency"Sort by currency value (supports "£$€¤¥¢").
sorter: "image"Sort by image alt value (see imgAttr option; added in v2.18.0).
sorter: "ipAddress"Sort by IP Address; Warning This parser was moved to the parser-network.js file in v2.18.0.
sorter: "url"Sort by url.
sorter: "isoDate"Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD; these formats can be followed by a time).
sorter: "percent"Sort by percent.
sorter: "usLongDate"Sort by date (U.S. Standard, e.g. Jan 18, 2001 9:12 AM or 18 Jan 2001 9:12 AM (new in v2.7.4)).
sorter: "shortDate"Sort by a shortened date (see dateFormat; these formats can also be followed by a time).
sorter: "time"Sort by time (23:59 or 12:59 pm).
sorter: "metadata"Sort by the sorter value in the metadata - requires the metadata plugin.

Check out the headers option to see how to use these parsers in your table (example #1).

Or add a header class name using "sorter-" plus the parser name (example #2), this includes custom parsers (example #3).
1 2 3
Array Internally stored Array of headers that represent each column (v2.21.0)

The table.config.$headers variable contains ALL header cells, not all of which contain sorting information (data-attributes, class names or sorting information).

This variable targets the last sortable header cell in a particular column; unless an entire column is completely unsortable (checkbox column), then it just picks the last cell in that column.

To make that description less confusing, look at the HTML in the config.$headers documentation, only the four middle rows (header-index 1-4) will be contained within this variable:
// the resulting config.$headerIndexed for the HTML example in config.$headers will look like this:
console.log( table.config.$headerIndexed );
/* outputs : [
  $('<th data-column="0">header-index 1</th>'),
  $('<th data-column="1">header-index 2</th>'),
  $('<th data-column="2">header-index 3</th>'),
  $('<th data-column="3">header-index 4</th>')
] */

* NOTE * This variable contains an array of jQuery objects, it is not a collection of jQuery objects, i.e.
var $column = table.config.$headerIndexed[ 0 ]; // jQuery object returned
console.log( $column.hasClass('foo') ); // how to access information

var $headers = $( table.config.$headerIndexed ); // make a collection of jQuery objects
// then use collection manipulation functions
$headers.each(function(){
  console.log( $(this).text() );
});
jQuery Object Internal list of all table header cells (v2.8)

*NOTE* The header cells within rows with the cssIgnoreRow class (default is "tablesorter-ignoreRow" will not be included in this variable.

Header cells in not-ignored rows are targeted using the jQuery selector from the selectorHeaders option

Please note that the headers cells are simply an array of targetted header cells and should not be targeted using a column index. For example, given the following table thead markup, the header-index counts the header th cells and does not actually match the data-column index when extra rows and/or colspan or rowspan are included in any of the header cells:
<thead>
	<tr>
		<th colspan="4" data-column="0" class="sorter-false">header-index 0</th>
	</tr>
	<tr>
		<th data-column="0">header-index 1</th>
		<th data-column="1">header-index 2</th>
		<th data-column="2">header-index 3</th>
		<th data-column="3">header-index 4</th>
	</tr>
	<!-- the next row WILL NOT be included in the config.$headers variable -->
	<tr class="tablesorter-ignoreRow">
		<th colspan="2" data-column="0">This cell is not included in the config.$headers</th>
		<th colspan="2" data-column="2">This cell is not included in the config.$headers</th>
	</tr>
	<tr>
		<th colspan="2" data-column="0" class="sorter-false">header-index 5</th>
		<th colspan="2" data-column="2" class="sorter-false">header-index 6</th>
	</tr>
</thead>
So, in the above example, to target the header cell in the second table column (data-column index of 1), use the following code: table.config.$headers.filter('[data-column="1"]') or table.config.$headers.eq(2).

The table.config.$headers variable is useful within callback functions or when writing widgets that target the table header cells.
DOM element Internally stored DOM table element (v2.17.5)

The table.config.table variable is useful when certain callback functions only pass the config object; originally you could use config.$table[0], but this saves that small extra trouble.
jQuery Object Internally stored jQuery object of the table (v2.7.1)

The table.config.$table variable is useful within callback functions or when writing widgets that target the table.
Object Internally stored object of column specific sort variables (v2.24.0; v2.27.0)

This object is defined as follows:
// $('table')[0].config.sortVars -> result
[{
  // column 0
  count: 0, // click count; used as index for order value
  order: [ 0, 1, 2 ], // default sort (sortReset: true)
  lockedOrder: false  // true if column order is locked (read only)
},{
  // ...
},{
  // column n
  count: 0, // click count; used as index for order value
  order: [ 0, 1, 2 ], // default sort (sortReset: true)
  lockedOrder: false  // true if column order is locked (read only)
}]
  • count
    • The initial value is -1.
    • The value is incremented each time the user clicks on a header cell; but it resets to zero once it reaches the end of the order array.
  • order
    • An array that contains the sort sequence for each column.
    • 0 indicates an ascending sort.
    • 1 indicates a descending sort.
    • 0 indicates a reset sort (initial unsorted rows).
    • Locked sorts will contain either [0, 0] or [1, 1] determined by the lockedOrder setting.
    • Setting these values to [2, 2] will lock in an unsorted column, but the unsort arrows will still be visible; use a "sorter-false" class instead.
    • The values of this order can only be modified after tablesorter has initialized.
  • lockedOrder
    • See the lockedOrder setting.
    • It's readonly because it is set during initialization and not used again (future use by a widget?)
jQuery Object Internally stored jQuery object of table non-info block tbodies (v2.7.1)

jQuery object of sortable tbodies.

Caution! These tbodies are the ones without a class name from the cssInfoBlock option, so the indexing of this jQuery object does not match the actual table tbody indexes.

The table.config.$tbodies variable is useful within callback functions or when writing widgets that target the table.
Boolean Boolean value indicating that tablesorter has been initialized on a table

This variable is not stored within the config, as the config would not be defined (an alternative method of determining if tablesorter has been initialized).

Access it as follows: $('table')[0].hasInitialized. It is true while tablesorter is active on a table, and false if tablesorter was destroyed.
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)

Access this internal value after tablesorter has initialized. It is also included as a variable in the filterEnd event so you can update an external count like this:
$('table').bind('filterInit filterEnd', function(event, data){
    // use data.filteredRows or this.config.filteredRows
    $('.filter-rows').html( data.filteredRows );
    $('.total-rows').html( data.totalRows );
});

If using the pager plugin or widget, the value returned from the filterEnd event will not be accurate, so you'll need to bind to the pagerComplete event instead:
$('table').bind('filterInit filterEnd pagerComplete', function(event, data){
    // Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
    // both objects contain data.filteredRows & data.totalRows
    $('.filter-rows').html( data.filteredRows );
    $('.total-rows').html( data.totalRows );
});
Access the widgetOptions (wo) using any of these methods:

// pure js, get the first table (zero index)
var wo = document.getElementsByTagName('table')[0].config.widgetOptions;
// or by table ID
var wo = document.getElementById('mytable').config.widgetOptions;

// using jQuery, get first table (zero index)
var wo = $('table')[0].config.widgetOptions;
// or from the jQuery data
var wo = $('#mytable').data('tablesorter').widgetOptions;
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.

The table.config.widgetOptions.filter_$anyMatch variable contains one more more search inputs, and is dynamically updated if the bindSearch function is called; make sure to set the flag to force a new search so that the values of the altered filters is updated appropriately.
jQuery Object Only available when the filter widget is active. This variable contains all table cells within the filter row.

Use the table.config.$filters variable when access to filters is needed. Note! This variable contains the table cell and not the actual input because the filter_formatter function allows adding other types of value selectors (e.g. jQuery UI slider).
jQuery Object Only available when the filter widget is active. This variable contains all external search inputs bound using the bindSearch function.

The table.config.widgetOptions.filter_$externalFilters variable contains an array of jQuery objects pointing to all external inputs, even if the bindSearch function is used multiple times.
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.
Numeric Only available when the filter widget is active. This variable contains the current number of filtered rows (v2.17.4; v2.17.5)

This internal value will show an accurate number of filtered rows; which means the count won't include any rows from "information-only" tbodies.

Access this internal value at any time after the filter widget has initialized, or as a shortcut it is included as a variable in the filterEnd event so you can update an external count like this:
$('table').bind('filterInit filterEnd', function(event, data){
    // use data.filteredRows or this.config.filteredRows
    $('.filter-rows').html( data.filteredRows );
    $('.total-rows').html( data.totalRows );
});

If using the pager plugin or widget, the value returned from the filterEnd event will not be accurate, so you'll need to bind to the pagerComplete event instead:
$('table').bind('filterInit filterEnd pagerComplete', function(event, data){
    // Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
    // both objects contain data.filteredRows & data.totalRows
    $('.filter-rows').html( data.filteredRows );
    $('.total-rows').html( data.totalRows );
});
jQuery Object Only available when the stickyHeaders widget (not the css3 version) is active.

The table.config.widgetOptions.$sticky variable contains a jQuery object pointing to a cloned table containing the sticky header. The table contained within this variable has a class name of "containsStickyHeaders" versus the original table with a class name of "hasStickyHeaders".
Access the pager options (p) using any of these methods:

// pure js, get the first table (zero index)
var p = document.getElementsByTagName('table')[0].config.pager;
// or by table ID
var p = document.getElementById('mytable').config.pager;

// using jQuery, get first table (zero index)
var p = $('table')[0].config.pager;
// or from the jQuery data
var p = $('#mytable').data('tablesorter').pager;
These methods are the same for both the pager addon and the pager widget.

*NOTE* This pager variable also contains all of the default pager option settings.

*NOTE* When using the pager widget, changing a value within the widgetOptions for the pager may not update the pager as expected. The pager widget uses most of the values within config.pager instead of the pager widgetOptions after initialization.
jQuery Object Contains a jQuery object pointing to a pager block(s).

The table.config.pager.$container variable is targeted using the pager container option and will have a class name of "tablesorter-pager" applied.

The container(s) may include the pager navigation arrows, page size selector, page selector and/or output block; the contents are completely customizable and all components are optional.
jQuery Object Contains a jQuery object pointing to an empty select within the pager block(s).

The table.config.pager.$goto variable is targeted using the pager cssGoto option.

The contents of this select element are dynamically updated if the page size is changed or if the table gets filtered.
jQuery Object Contains a jQuery object pointing to a select with the desired page size settings already in place.

The table.config.pager.$size variable is targeted using the pager cssPageSize option.

The contents of this select element must be set up with the desired page size settings before initializing tablesorter.

Also, because Internet Explorer does not appear to get the select value from the option text, please include a value attribute with all options. For example:
<select class="pagesize">
  <option value="10">10</option>
  <option value="20">20</option>
  <option value="30">30</option>
  <option value="40">40</option>
</select>
Array Contains an array of zero-based row indexes of rows that currently displayed within the table.

For example, if you want to get the parsed values for the rows currently displayed within the pager, use the table.config.pager.cacheIndex variable as follows:
var c = $('table')[0].config,
	p = c.pager,
	cache = c.cache[0].normalized,
	cachedValues = [];
$.each( p.cacheIndex, function(i, v) {
	// cache[v] will be an array of parsed values for each cell in selected row
	cachedValues.push( cache[v] );
});
the p.cacheIndex variable get updated whenever the table is sorted, filtered or the pager changes pages or page size.
Numeric Contains a one-based index of the first row visible in the pager.

The {startRow} tag in the pager output option is replaced by this value; and it does not correspond to the row index within the cache.
Numeric Contains a one-based index of the last row visible in the pager.

The {endRow} tag in the pager output option is replaced by this value; and it does not correspond to the row index within the cache.
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.

The {filteredPages} tag in the pager output option is replaced by this value.
Numeric Contains the number of rows accessible by the pager after the table is filtered. It equals the totalRows if no filters are applied.

The {filteredRows} tag in the pager output option is replaced by this value.
Numeric Contains a one-based index of the current page visible in the pager.

The {page} tag in the pager output option is replaced by this value.

Initially, this value is set by either the pager page option or from local storage if the savePages option is true. It is then updated by user interaction with the page selector (targeted by the cssGoto option or programmically by the pageSet or pageAndSize method.
Numeric Contains the currently selected page size.

Initially, this value is set by either the pager size option or from local storage if the savePages option is true. It is then updated by user interaction with the size selector (targeted by the cssPageSize option or programmically by the pageSize or pageAndSize method.
Numeric Contains the total page count as determined by the page size setting.

The {totalPages} tag in the pager output option is replaced by this value.
Numeric Contains the total number of rows within the table

The {totalRows} tag in the pager output option is replaced by this value.
Removed Variables
jQuery Object Internal list of all extra table header cells (v2.16.2; removed v2.21.3)

This variable was removed due to it causing memory leak issues. To now find extra headers use config.namespace as follows:

$( config.namespace + '_extra_headers' )

When the bindEvents function is used, the extra (external) header cells are added to this variable, and automatically updated with the table headers (config.$headers).

So, when writing a custom widget that clones the table header, there is no longer a need to update the header class names, it's all done automatically.

jQuery Object Internal list of all extra (cloned) table elements (v2.19.0; removed v2.21.3)

This variable was removed due to it causing memory leak issues. To find extra tables use config.namespace as follows:

$( config.namespace + '_extra_table' )

Some widgets need to duplicate parts of the original table to provide functionality (e.g. stickyHeaders, scroller). This saved variable will either not exist or contain a jQuery object pointing to the cloned table elements.

This variable was added for the uitheme widget to allow dynamic updating of themes to the original table as well as all cloned parts.

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 adds a colgroup element to the table when widthFixed is true.

A new colgroup with col elements is only added if:
  • widthFixed is true.
  • A predefined colgroup element does not already exist in the table *.
* Note If a colgroup was added by the plugin, calling this function additional times will refresh the set widths

Also, the col elements within the colgroup are set with a percentage width to dynamically maintain the fixed column width ratios.

Use it as follows:
$.tablesorter.fixColumnWidth( table );
  • table - table DOM element (or jQuery object) of table.
This function detaches the targeted tbody from the DOM to allow faster manipulation of the tbody contents (v2.4).
Use it as follows:
$.tablesorter.processTbody( table, $(tbody), getIt );
  • table - table DOM element (or jQuery object) of table containing the tbody.
  • $(tbody) - tbody jQuery object.
  • getIt - Boolean flag (optional if false).
When calling the function, to get a tbody, set the getIt boolean parameter to true and the removed tbody is returned; setting this option to false or optionally not including it will restore the tbody.
Here is a basic example of how this function is used:
var tbodyIndex, _tbody,
	table = $('#my-table')[0],
	tbodies = table.tBodies, // use table.config.$tbodies for all tbodies EXcluding information only tbodies
for (tbodyIndex = 0; tbodyIndex < tbodies.length; tbodyIndex++) {
	// detach tbody from table
	_tbody = $.tablesorter.processTbody( table, tbodies[tbodyIndex], true );
	// do something magical to the tbody
	_tbody.addClass('unicorn');
	// restore tbody
	$.tablesorter.processTbody( table, _tbody );
}
Please note that completely detaching the tbody was found to be a much quicker method of manipulating DOM elements than just hiding the tbody; this is especially true in older browsers.
This function adds the processing (indeterminant loading icon) to specific or all header cells while processing table elements (v2.4).

Use it as follows:
$.tablesorter.isProcessing( table, toggle, $ths );
  • table - table DOM element (or jQuery object) of table.
  • toggle - Boolean flag.
  • $ths - jQuery object of targeted header cells (optional; if excluded all header cells are targeted).
When calling the function, set the toggle option to add (true) or remove (false) process indicators. Include any specific header cells within the $ths variable with which to add the process indicator. When $ths is not defined and a sort is applied, the currently sorted header cells will show process indicators.

All this function does is add or remove a class name of "tablesorter-processing" and the class name contained within the cssProcessing option.

Here is a basic example of how this function is used:
$('table').bind('sortBegin sortEnd', function(event, table){
	// this is included with the basic functionality of tablesorter
	$.tablesorter.isProcessing( this, event === 'sortBegin' );
});
Please note that currently the processing icons do not animate (see issue #158). This is due to javascript being a single-threaded, meaning it only does one task at a time, and maximizing the sorting script. So lots of processing is needed to sort & rebuild the table and thus it has no time for animation. If someone knows of a better solution, please share!
This function empties ALL of the table tbodies (v2.17.2).

Use it as follows:
$.tablesorter.clearTableBody( table );
  • table - table DOM element (or jQuery object) of table.
Please note that this function uses jQuery empty(). All data & event handlers are removed. No where within the tablesorter script or included widgets is this function used, it is left intact for backwards compatibility.
This function adds header event listeners to the targeted cells (v2.8; v2.16.2).

Use it as follows:
$.tablesorter.bindEvents( table, $headers );
  • table - table DOM element (or jQuery object) of table.
  • $headers - jQuery object of targeted cells.
This function allows you to bind the same header event listeners to external headers cells (usually clones of the original table). This includes the triggered sort event, left click (only) to sort, ignoring long clicks (> 250ms), pressing enter to trigger a sort (must have focus and a tabindex attribute) and cancelling selection of text (if the option is set).

To ensure the columns match the original table, include data-column attributes pointing to the desired column.

Here is a basic example of how this function is used:
var $table = $('table'),
	// make a copy of the table
	$clonedTable = $table.clone().addClass('clonedTable').insertAfter($table);
// remove stuff we don't need in the clone
$clonedTable.find('tfoot,tbody').remove();
// bind events to the cloned headers
$.tablesorter.bindEvents( $table, $clonedTable.find('th') );
In v2.16.2, this function now saves all extra (external) headers to the config.$extraHeaders variable which allows the plugin to automatically update the sort status.
This function restores the table headers cells with their original content (v2.8).

The original header cell content is saved, within the headerContent variable array, before the headerTemplate is applied and before the onRenderTemplate and onRenderHeader callbacks are executed.

Use it as follows:
$.tablesorter.restoreHeaders( table );
  • table - table DOM element (or jQuery object) of table.
Please note that only header cells that still contain a div with a class name of tablesorter-header-inner will have their contents restored; it assumes that the contents have already been restored.
This function completely removes tablesorter, including all widgets, associated data & event handlers from the table (v2.3.2).

Use it as follows:
$.tablesorter.destroy( table, removeClasses, callback );
  • table - table DOM element (or jQuery object) of table.
  • removeClasses - Boolean flag
  • callback - Function executed once tablesorter has been removed.
When calling the function, set the removeClasses option to true to include removing of the "tablesorter" class name, tablesorter theme name (e.g. "tablesorter-blue") and the class name applied by the tableClass option. The callback function only provides a table (DOM element only) parameter.

Here is a basic example of how this function is used:
$.tablesorter.destroy( table, true, function(table){
	alert('tablesorter has been removed! No sort for you!');
});
Please note that only header cells that still contain a div with a class name of tablesorter-header-inner will have their contents restored; it assumes that the contents have already been restored.
This function sorts the a & b parameter using a natural sort (v2.12).

Access it as follows:
$.tablesorter.sortNatural(a, b);
  • a - string.
  • b - string to compare.
Here is a basic example of how this function is used:
var myArray = [ '1a', '10a', '2a', '2b' ];
// result: ["1a", "2a", "2b", "10a"]
myArray.sort(function(a,b) { return $.tablesorter.sortNatural(a, b); });
Please note that this natural sort function only accepts strings (added v2.0.6; renamed v2.12).
This function sorts the a & b parameter using a basic sort (renamed v2.12).

Access it as follows:
$.tablesorter.sortText(a, b);
  • a - string.
  • b - string to compare.
Here is a basic example of how this function is used:
var myArray = [ '1a', '10a', '2a', '2b' ];
// result: ["10a", "1a", "2a", "2b"]
myArray.sort(function(a,b) { return $.tablesorter.sortText(a, b); });
This function replaces basic accented characters to better sorting & filtering of table contents (v2.2).

Use it as follows:
$.tablesorter.replaceAccents(string);
  • string - a string to process & replace accented characters.
Here is a basic example of how this function is used:
$.tablesorter.replaceAccents("áàâãä"); // result: "aaaaa"
This function is used when the sortLocaleCompare option is set to true. Please refer to the option and the demo for more details on the defaults values and how to add more accented characters.
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).

Use it as follows:
$.tablesorter.isValueInArray(value, array);
  • value - value to find within the array.
  • array - array (sortList) to search for the value.
Sadly, this function has limited usefulness outside of tablesorter. It is only meant to search a sortList array and determine if a column (value) is already contained within it. Here is a basic example of how this function is used:
var sortList = [ [1,0], [2,0], [0,0] ];
// result: 1
$.tablesorter.isValueInArray(2, sortList);
After v2.15.6, this function returns a zero-based index of the position of the value within the array parameter, or -1 if the value is not in the array. Previously, this function returned a boolean value of true if the value was contained within the array, or false if not.
This function allows the adding of custom parser scripts to the tablesorter core.

Access it as follows:
$.tablesorter.addParser(myParser);
  • myParser - object containing parser code.
The myParser object must contain a proper template. The template must include an id, is, format and type blocks. Please refer to the writing custom parsers demo page for more details & an example.
This function allows to add custom methods for config object (v2.21.0).

Access it as follows:
$.tablesorter.addInstanceMethods(methods);
  • methods - an object containing methods to be added, indexed by method names. These methods can use config object by refering this.
Take a look at instanceMethods variable description for more details.
This function returns the named parser object.

Access it as follows:
$.tablesorter.getParserById(name);
  • name - the name (or id) of the parser.
Use this function as follows:
var parser = $.tablesorter.getParserById("currency"),
	value = parser.format('100%'); // returns 100 (number type, not a string)
This function allows the checking to see if a widget is installed (v2.17.4).

Access it as follows:
$.tablesorter.hasWidget( table, 'mywidget');
  • table - table element or jQuery object of the selected table.
  • 'mywidget' - ID of the widget to check.
This function returns a boolean value, where true means the widget is currently installed and active; and false means the widget is not installed.

Use this function as follows:
$.tablesorter.hasWidget( $('table'), 'zebra' ); // true
This function allows the adding of custom widget scripts to the tablesorter core (v2.19.0).

In v2.19.0, a "refreshing" parameter was added to the remove widget function to indicate that the widget will be refreshed so it will only be temporarily removed (see this demo for more details).

Access it as follows:
$.tablesorter.addWidget(myWidget);
  • myWidget - object containing widget code.
The myWidget object must contain a proper template. The template must include an id and format blocks. The priority, options, init and remove blocks are optional.

Please refer to the writing custom widgets demo page for more details & an example.
This function returns the named widget object.

Access it as follows:
$.tablesorter.getWidgetById(name);
  • name - the name (or id) of the widget.
Use this function as follows:
var widget = $.tablesorter.getWidgetById("saveSort"),
	table = $('table')[0];
// apply save sort widget to a table; but it will get removed if the refreshWidgets method
// is triggered, unless the table.config.widgets array contains this widget name/id
widget.format( table, table.config, table.config.widgetOptions );
This function applys (refreshes) all currently selected widgets on a table (v2.16.0; v2.19.0).

Use it as follows:
$.tablesorter.applyWidget( table, init, callback );
  • table - table DOM element (or jQuery object) of table.
  • init - optional, boolean initialization flag.
  • callback - optional, a function executed after all widgets have been applied; the only parameter is table (v2.19.0).
The init flag is only set to true to extend the default option values from the widget options block. If the widget(s) have already been applied to the table, just leave this parameter undefined.

This function is called when the applyWidgets method is triggered.
This function removes, then reapplies all currently selected widgets on a table (v2.4; v2.19.0).

In v2.19.0, this function was modified to internally use the removeWidget function & a "refreshComplete" event is now triggered upon completion.

Use it as follows:
$.tablesorter.refreshWidgets( table, doAll, dontapply );
  • table - table DOM element (or jQuery object) of table.
  • doAll - optional, boolean flag.
  • dontapply - optional, boolean flag.
The doAll flag is set to true if all widgets contained with the global $.tablesorter.widgets array are to be removed.
When doAll is false, only widgets not contained within the config.widget option are removed; then if the dontapply flag is false, the widgets named in that option are reapplied (without removing them).

This function is called when the refreshWidgets method is triggered.
This function removes selected widgets (v2.19.0).

Use it as follows:
$.tablesorter.removeWidget( table, names, refreshing );
  • table - table DOM element (or jQuery object) of table.
  • names - string (space or comma separated widget names), an array of widget names, or if true all installed widgets are removed.
  • refreshing - if true, the widget name will not be removed from the widgets option; any other setting and the name will be removed.
This function is used by the refreshWidgets function (v2.19.0).
This function returns the column data from an object based on a column index or classname/id (v2.21.1).

Use it as follows:
$.tablesorter.getColumnData( table, object, key );
  • table - table DOM element (or jQuery object).
  • object - object containing zero-based column indexes or column class names as a key (e.g. table.config.headers or table.config.widgetOptions.filter_functions; any data found as the value (of the key : value pair) will be returned.
  • key - key to be Object key; this can be a zero-based column index or header class name/id.
As a full example, say you have a header cell with a class name of "event". And you want to use the textExtraction function for that column, then you would use this function as follows:
var table = $('table')[0],
textExtractionFunction = $.tablesorter.getColumnData( table, table.config.textExtraction, ".event" );
The ".event" key can be replaced with a zero-based column index, if the textExtraction option is set up using indexes.

This function is sometimes used in conjunction with the getData function. This function is called first because the getData function uses the result in the configHeaders parameter - the config.headers option result from this function would be an object and not a function.
This utility function returns the entire column text (raw and parsed) as well as other data (v2.21.4; v2.24.0).

Use it as follows:
$.tablesorter.getColumnText( table, column, callback, rowFilter );
  • table - table DOM element (or jQuery object).
  • column - zero-based column index or 'all'.
  • callback - callback function that is called while obtaining data for each cell within the specified column.
  • rowFilter - can be a jQuery selector, function or element to allow targeting specific rows (e.g. ":visible" or ":not(.child-row)"); this parameter is used in a jQuery .is() function (v2.24.0).
When using the callback, there is only one argument (object) passed to this function; it contains the following:
  • tbodyIndex - the tbody zero-based index of the current cell.
  • rowIndex - the row zero-based index of the current cell.
  • $row - a jQuery object targeting the current row being processed.
  • $cell - a jQuery object targeting the curretn cell being processed.
  • parsed - parsed text of the current cell.
  • raw - raw (unparsed) text of the current cell.
As an example, say you want to make the text of all cells with a value greater than 20 red (assuming the 'red' class name is defined in css). Do it as follows:
var table = $('table')[0];
// targeting the 4th column (zero-based index)
$.tablesorter.getColumnText( table, 3, function( data ) {
  if ( data.parsed > 20 ) {
    data.$cell.addClass('red');
  }
});
In this example, the goal is to get data from rows visible after filtering. When the callback returns false, that row/cell data will not be included in the resulting data:
var table = $('table')[0],
  // getting data from ALL columns, we're just skipping filtered out rows (rows with a "filtered" class)
  result = $.tablesorter.getColumnText( table, 'all', function( data ) {
    return !data.$row.hasClass('filtered');
  });
  // let's just assume this example is only showing filter matching rows (rows without a "filtered" class ;)
  // result = {
  //   raw    : [ [ 'r1c1', 'r1c2', ..., 'r1cN' ], [ 'r2c1', 'r2c2', ..., 'r2cN' ] ..., [ 'rNc1', 'rNc2', ..., 'rNcN' ] ],
  //   parsed : [ [ 'r1c1', 'r1c2', ..., 'r1cN' ], [ 'r2c1', 'r2c2', ..., 'r2cN' ] ..., [ 'rNc1', 'rNc2', ..., 'rNcN' ] ],
  //   $cell  : [ [ $r1c1,  $r1c2,  ..., $r1cN  ], [ $r2c1,  $r2c2,  ..., $r2cN  ] ..., [ $rNc1,  $rNc2,  ..., $rNcN  ] ]
  // }
If the callback isn't used, the function will return the cummulated data for the column (it does not include all of the parameters available within the callback function):
var table = $('table')[0],
  // targeting the 4th column (zero-based index)
  columnText = $.tablesorter.getColumnText( table, 3 );
  // columnText = {
  //   raw    : [ 'cell1', 'cell2', ..., 'celln' ],
  //   parsed : [ 'cell1', 'cell2', ..., 'celln' ],
  //   $cell  : [ $cell1,  $cell2,  ..., $celln  ]
  // }
When using the filter widget, you can ignore filtered rows using the following code:
var table = $('table')[0],
  // targeting the 4th column (zero-based index); callback function is an empty string & therefore ignored
  columnText = $.tablesorter.getColumnText( table, 3, '', ':not(.filtered)' );
  // columnText = {
  //   raw    : [ 'cell1', 'cell2', ..., 'celln' ],
  //   parsed : [ 'cell1', 'cell2', ..., 'celln' ],
  //   $cell  : [ $cell1,  $cell2,  ..., $celln  ]
  // }
All of these methods of gathering column data might be useful for custom widgets, etc.

* NOTE * All currently available widgets that gather data from a column will be updated to use this function in v2.22.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).

priority = jQuery data > meta > headers option > header class name

Use it as follows:
$.tablesorter.getData(headerCell, configHeaders, key);
  • headerCell - table DOM element (or jQuery object) of targeted header cell.
  • configHeaders - table.config.headers option for the current column.
  • key - get value for this option name, e.g. "sorter".
If the value of the "sorter" option is needed for a column, set the key to "sorter" and this function will return the set value, e.g. false, digit, currency etc.
Use this function as follows:
var column = 2,
	config = $('table')[0].config,
	headerCell = config.$headers.filter('[data-column="' + column + '"]');
// e.g. returns "false" if the header cell has the "sorter-false" class name
$.tablesorter.getData( headerCell, config.headers[column], "sorter" );
The reason there is a priority is because that is the order in which the values are searched, only the first (higher priority) value is returned.
This function converts a number string into a number type.

Use it as follows:
$.tablesorter.formatFloat(string, table);
  • string - a string possibly containing a number.
  • table - table DOM element (or jQuery object) of table (optional; required for non U.S. formatting).
If string is empty, not a string type, or not a number (after processing), the string itself is returned.
If table is not provided, the format float function will default to U.S. number formatting. The reason a table parameter is needed is to check the value of the usNumberFormat option.

This function uses the usNumberFormat option to determine if either commas or decimals are removed before converting the value within the string parameter into a number type variable. This function does not use the $.tablesorter.isDigit function.

Any numbers wrapped within parentheses are converted into negative numbers; but any other symbols (e.g. currency) are not removed and will cause this function to determine the string as a non-number (e.g. "$1.25" will be returned as a string).

Use this function as follows:
// result: -2345.67 if usNumberFormat option is true
$.tablesorter.formatFloat( "(2,345.67)", table );
This function determines if a string contains a number after removing commas, periods, quotes and spaces.

Use it as follows:
$.tablesorter.isDigit(string);
  • string - a string possibly containing a number.
This function will return a boolean value of true if the string parameter contains a number after all commas, decimals, quotes and spaces are removed, and still allow plus or minus signs, or the number wrapped in parenthesis (negative values).

Use this function as follows:
// boolean value of true returned
$.tablesorter.isDigit( "(2,345.67)" );
Adds the correct data-column indexing to all rows passed to this function (v2.16; v2.25.0).

In v2.25.0, if a config parameter is included, this function will only add a "data-column" attribute to cells where their internal cellIndex doesn't match its actual column index. This does not apply to internal usage where a "data-column" attribute is set on all header & footer cells.

Use it as follows:
// In v2.25.0, if a config parameter is included "data-columns" are not added
// to cells where their cellIndex and calculated column index match
$.tablesorter.computeColumnIndex($rows, config);
  • $rows - jQuery object of rows in which to add data-column indexes.
  • config - this is the table.config (table configuration variables) object.
Example result (without including config):
<tr>
	<td colspan="2" data-column="0">r0c0</td>
	<td data-column="2">r0c2</td>
</tr>
<tr>
	<td data-column="0">r1c0</td>
	<td data-column="1">r1c1</td>
	<td data-column="2">r1c2</td>
</tr>
Example result (including config):
<tr>
	<td colspan="2">r0c0</td> <!-- data-column="0" is not included because it matches the cellIndex property -->
	<td data-column="2">r0c2</td>
</tr>
<tr>
	<td>r1c0</td>
	<td>r1c1</td>
	<td>r1c2</td>
</tr>
This function allows adding/removing a row to the thead, to display any errors (v2.15; v2.23.1).

This function is ONLY included within the widget-pager.js and jquery.tablesorter.pager.js files; in version 3+, I plan to add it as a selectable option in a build.

In v2.23.1, a settings parameter was included to make it match the parametered returned by the jQuery .ajaxError() method.

In v2.23.0, this function will accept xhr and exception parameters provided by ajax error messages. To maintain backward compatibility, if xhr is a string, it will be treated as previous message parameter and displayed in the error row without modification.

Use it as follows:
$.tablesorter.showError( table, xhr, settings, exception );
  • table - table DOM element (or jQuery object) of the table.
  • xhr - a plain string, string of an HTML row, or the XMLHttpRequest (XHR) object from ajax error message.
  • settings - a plain object containing the ajax settings, as returned by the ajaxError method.
  • exception - exception string passed from the ajax error message.
This function will add a table row to the thead, with a class name from either the pager plugin cssErrorRow option setting, or the pager widget pager_css.errorRow option (the default class name is "tablesorter-errorRow"; and styled within each theme css file).

When passing this function a message string (in the xhr parameter), there are three possibilities:

  1. Plain string (with inline HTML is okay) - "<strong>table refuses to cooperate</strong>"
  2. HTML row string - '<tr><td colspan="' + table.config.columns + '">yeah, instead of showing your data... I am taking a nap</td></tr>' (the table.config.columns variable contains the number of table columns; use as needed)
  3. undefined - completely leave out a message parameter $.tablesorter.showError( table ); to remove all error rows from the table thead.
As of v2.23.0,
  • *WARNING* the table parameter no longer accepts multiple tables.
  • If the xhr parameter is not a string, then the pager ajaxError callback is called to allow modification of the displayed message.
Widget Functions
This filter widget function allows binding external search filters to the table (v2.13.3; v2.15).

Access it as follows:
$.tablesorter.filter.bindSearch(table, $els, false);
  • table - table DOM element (or jQuery object) of table.
  • $els - jQuery object of all input (search) elements to bind.
  • false - boolean flag to force a new search.

The table element will only process one table. So if you pass in a jQuery object, only the first table will be bound to the elements ($els).

The external elements ($els) will allow searching the table using "search" and "keyup" events (enter to start & escape to cancel the search), and uses the filter_liveSearch option, or delayed search.

Include a data-column="#" attribute (where # is the column number) in the search input, to specify to which column the search should apply ~ see this demo for a full example. Warning!, if no data-column attribute is added to the input, the input will be ignored.

In v2.15, use a data-column="all" to bind an external any-match search filter; but note that adding an external any-match filter using this method will not override the filter set by the filter_external option.

The third function parameter, false, is optional. When set to false it forces the inputs to update their values (same as setting the apply flag when using the setFilters function), and reapplies (forces) the current search to be applied again, even if the filter values have not changed; this allows changing the data column attribute dynamically. See the filter external inputs demo for an example.

Warning! If the third parameter is set to true the saved internal filters (config.$filters) will be replaced - not recommended!
This filter widget function allows the updating or replacing of filter select options from an external source. (v2.17.5):

Access it as follows:
$.tablesorter.filter.buildSelect( table, column, options, replace, onlyAvail );
  • table - table DOM element (or jQuery object) of table.
  • column - zero-based column index.
  • options - array of options, jQuery object of option elements, or HTML string of option elements to apply to the targeted select.
  • replace - a boolean value, which if true all options will be replaced; if false the options will be appended to the current list of options.
  • onlyAvail - an optional boolean flag, which will be ignored if the options parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if true, only the available options will be diplayed.
Use this function as follows:
// replace filter select options for the first column with 1,2,3,4
$.tablesorter.filter.buildSelect( $('table'), 0, [ 1, 2, 3, 4 ], true );

// append "Aaron" and "Fred" to the second column's filter select options. These options will remain unsorted.
$.tablesorter.filter.buildSelect( $('table'), 1, $('<option>Aaron</option><option>Fred</option>'), false );
Please be aware that this function will allow you to modify the select options, but as soon as the user filters any column, all of the select options will refresh and obtain options from the table column, or from the filter_selectSource function.
This filter widget function returns all the cached values of the set table column (v2.16.0):

This function respects the parsed data setting for the column, so it uses the filter_useParsedData option, "filter-parsed" class on the header, or the parser parsed flag settinng (ref).

Use it as follows:

$.tablesorter.filter.getOptions( table, column, onlyAvail );
  • table - table DOM element (or jQuery object) of table.
  • column - zero-based column index.
  • onlyAvail - an optional boolean flag, which will be ignored if the options parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if true, only the available options will be diplayed.
Use this function as follows:
// external filter select
var index, len,
	opts = '',
	$table = $('table'),
	column = 0, // first column
	onlyAvail = false, // if true, available rows (visible rows after filtering) are returned
	array = $.tablesorter.filter.getOptions( $table, column, onlyAvail );

// process array; sort & remove duplicates (added v2.23.4)
arry = $.tablesorter.filter.processOptions( $table, column, array );
len = arry.length;

// build options
for ( index = 0; index < len; index++ ) {
	opts += '<option value="' + array[ index ] + '">' + array[ index ] + '</option>';
}
$('select.external').html( opts );

Please be aware that this function does not process the array, so the array may contain duplicates and will not be sorted.

The filter processOptions function was added in v2.23.4 which performs those actions.
This filter widget function returns an array of sorted column data will duplicates removed (v2.23.4).

Use it as follows:
$.tablesorter.filter.processOptions( table, column, array );
  • table - table DOM element (or jQuery object) of table.
  • column - zero-based column index (optional).
  • array - An array of items to process.
The column parameter is optional, but if included it is used:
  • To check the column header for a filter-select-nosort class name to prevent the sorting of options.
  • To check the column header for a filter-select-sort-desc class name to preform a descending sort of options.
  • To check tablesorter's textSorter option in case there are column specific sorting algorhithms set.
See the getOptions function description or the filter_selectSource option (under "An object containing column keys"; getJSON) for examples which use this function.
This filter widget function allows getting an array of the currently applied filters (v2.9; v2.15)

Access it as follows:
$.tablesorter.getFilters(table, flag);
  • table - table DOM element (or jQuery object) of table.
  • flag - boolean flag (optional; false by default; filter values obtained from the cache), added v2.15;
Use this function as follows:
// use $('table') or $('table.hasFilters') to make sure the table has a filter row
// only required if the stickyHeaders or scroller widget is being used (they duplicate the table)
$.tablesorter.getFilters( $('table') );
This function returns an array of filter values (e.g. [ '', '', '', '', '', '2?%' ]), or false an empty array (v2.27.0) if the selected table does not have a filter row or any associated inputs. It will also return an additional parameter if an external input with data-column="all" containing the value used when matching any table column.

In v2.27.0, this function will always return an array.
In v2.15, this function will also return values from any external filters (set either by the filter_external option or using the bindSearch function) - with or without an internal filter row.

If the second parameter is set to true, it forces the function to get all of the current filter values directly from the inputs. Otherwise, by default, the function returns the last search as found in this stored data $('table').data('lastSearch');.
This filter widget function allows setting of the filters; include a true boolean to actually apply the search (v2.9; v2.24.3):

Access it as follows:
$.tablesorter.setFilters(table, filter, apply);
  • table - table DOM element (or jQuery object) of table.
  • filter - array of filter values to apply to the table.
  • apply - boolean flag, if false (default setting; default is now true as of v2.24.3), the input values are updated, but the search is not applied to the table.
Use this function as follows:
// update filters, but don't apply the search
$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ], false );

// update filters, AND apply the search (apply is undefined; defaults to true in v2.24.3+)
$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ] ); // this will now use the search method
This function returns true if the filters were sucessfully applied, or false if the table does not have a filter row.

In v2.24.3, if the apply parameter is left undefined, it will now default to true.

As of v2.15, this function will also set values in any external filters (set either by the filter_external option or using the bindSearch function). An additional search parameter can be included to match any column, but please include an external input with data-column="all" using the bindSearch function so your users will know that a search has been applied.

Also, changed is that when a true value is passed as a third parameter, the search is forced to refresh on the table; otherwise, if the filters set in the search exactly match the previous search, it would be ignored - this was added to prevent numerous ajax calls with exactly the same search or sort parameters (when using the pager).
This resizable widget function allows resetting column width changes and clearing out the saved set widths (v2.4; v2.10.1)

Use it as follows:
$.tablesorter.resizableReset(table, refreshing);
  • table - table DOM element (or jQuery object) of table(s).
  • refreshing - if this flag is set to true, the stored resize settings will not be cleared; all other settings will clear the storage.
This function is used when the user right-clicks on the table header (the refreshing flag is undefined at that time to allow saving the changes).
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).

There is no built-in resize event for non-window elements, so when this function is active it triggers a resize event when the header cell changes size. So, if you are writing your own widget and need a header resize event, just include the jquery.tablesorter.widgets.js file, or just the extract the function from that file.

Access it as follows:
$.tablesorter.addHeaderResizeEvent(table, disable, { timer : 250 });
  • table - table DOM element (or jQuery object) of table.
  • disable - boolean flag, if false events for the targeted table are disabled.
  • timer - currently only the timer option is available for modification.
Enable these triggered events as follows:
var table = $('table')[0],
    disable = false,
    options = {
      timer : 250 // header cell size is checked every 250 milliseconds (1/4 of a second)
    };
$.tablesorter.addHeaderResizeEvent( table, disable, options );
Then use it in your custom widget as follows:
$(table).on('resize', function(event, columns){
  // columns contains an array of header cells that were resized
  // this seemed like a better idea than firing off a resize event for every
  // column when the table adjusts itself to fit within its container
  event.stopPropagation(); // optional
  // do something
  console.log( columns );
});
To disable these resize events, use this code:
// Disable resize event triggering:
var table = $('table')[0];
$.tablesorter.addHeaderResizeEvent( table, true );
This function allows saving specific table data (especially widgets) to local storage (cookie fallback for no browser support) (v2.1)

Access it as follows:
$.tablesorter.storage(table, key, value, options);
  • table - table DOM element (or jQuery object) of table.
  • key - name of the variable to save
  • value - value of the variable that is saved (for saving only); set as undefined if wanting to get a value with options.
  • options - storage options; see below
This function attempts to give every table a unique identifier using both the page url and table id (or index on the page if no id exists), by default. Here is a usage example and a look at what is stored within the local storage:
$.tablesorter.storage( $('#tablesorter-demo')[0], 'test', '123');
// stored under the "test" value as {"/tablesorter/docs/":{"tablesorter-demo":"123"}}

The saved table url & id can be overridden by setting table data attributes data-table-page (url) and data-table-group (id), as in this sample markup:
<table class="tablesorter" data-table-page="mydomain" data-table-group="financial">...</table>)
To change the default data attributes, use the options to modify them as follows:
$.tablesorter.storage( table, key, value, {
  // table id/group id
  id  : 'group1',
  // this group option sets name of the table attribute with the ID;
  // but the value within this data attribute is overridden by the above id option
  group: 'data-table-group',

  // table pages
  url : 'page1',
  // this page option sets name of the table attribute with the page/url;
  // but the value within the data attribute is overridden by the above url option
  page: 'data-table-page',

  // Option added v2.21.3; if `true` the storage function will use sessionStorage
  // if not defined, the `config.widgetOptions.storage_useSessionStorage` setting is checked
  // if no settings are found, it will default to `false`, and use localStorage
  useSessionStorage : false
});
The priority of table ID settings is as follows:
  1. options.id setting
  2. Table data attribute ("data-table-group" by default) value
  3. widgetOptions.storage_tableId option
  4. Table id attribute
  5. Index of the table (compared to other tables with a "tablesorter" class name) on the page
The priority of table url (group) settings is as follows:
  1. options.url setting
  2. Table data attribute ("data-table-page" by default) value
  3. widgetOptions.storage_fixedUrl option value
  4. config.fixedUrl option value
  5. window.location.pathname

The storage_fixedUrl widget option allows you to override the current page url (it doesn't need to be a url, just some constant value) and save data for multiple tables across a domain. The value from this option has a lower priority than the options id or group settings (see priority list above).

When using the storage utility to get a value and use custom table options, set the value parameter as undefined.

Lastly, this storage utility function needs the parseJSON function available in jQuery v1.4.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