mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
2709 lines
116 KiB
HTML
2709 lines
116 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>jQuery plugin: Tablesorter 2.0</title>
|
|
|
|
<!-- jQuery -->
|
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
|
|
|
|
<!-- Demo stuff -->
|
|
<link rel="stylesheet" href="css/jq.css">
|
|
<link href="css/prettify.css" rel="stylesheet">
|
|
<script src="js/prettify.js"></script>
|
|
<script src="js/docs.js"></script>
|
|
|
|
<!-- Tablesorter: required -->
|
|
<link href="../css/theme.blue.css" rel="stylesheet">
|
|
<script src="../js/jquery.tablesorter.js"></script>
|
|
<script src="../js/jquery.tablesorter.widgets.js"></script>
|
|
<script>
|
|
$(function() {
|
|
$("#tablesorter-demo").tablesorter({theme:'blue',sortList:[[0,0],[2,1]],widgets:['zebra'],widthFixed:true});
|
|
$(".compatibility").tablesorter({theme:'blue',sortList:[[0,0]],widthFixed:true});
|
|
$("table.options").tablesorter({theme:'blue',sortList:[[0,0]],headers:{3:{sorter:false},4:{sorter:false}},widgets:['stickyHeaders'],widthFixed:true});
|
|
$("#method,#event").tablesorter({theme:'blue',sortList:[[0,0]],headers:{1:{sorter:false},2:{sorter:false}},widgets:['stickyHeaders'],widthFixed:true});
|
|
});
|
|
</script>
|
|
</head>
|
|
<body id="root">
|
|
<div id="banner">
|
|
<h1>table<em>sorter</em></h1>
|
|
<h2>Documentation</h2>
|
|
<h3>Flexible client-side table sorting</h3>
|
|
</div>
|
|
|
|
<div id="main">
|
|
<p>
|
|
<strong>Author:</strong> Christian Bach<br>
|
|
<strong>Version:</strong> <a class="current-version" href="http://github.com/Mottie/tablesorter/downloads">2.1+</a> (forked from <a href="http://tablesorter.com/docs/">version 2.0.5</a>, <a href="https://github.com/Mottie/tablesorter/wiki/Change">changelog</a>)<br>
|
|
<strong>Licence:</strong>
|
|
Dual licensed under <a class="external" href="http://www.opensource.org/licenses/mit-license.php">MIT</a>
|
|
or <a class="external" href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses.
|
|
</p>
|
|
|
|
<a id="Contents"></a>
|
|
<h1>Contents</h1>
|
|
<ol>
|
|
<li><a href="#Introduction">Introduction</a></li>
|
|
<li><a href="#Demo">Demo</a></li>
|
|
<li><a href="#Getting-Started">Getting started</a></li>
|
|
<li><a href="#Examples">Examples</a></li>
|
|
<li><a href="#Configuration">Configuration</a></li>
|
|
<li><a href="#Widget-options">Widget Options</a> (v2.1)</li>
|
|
<li><a href="#Methods">Methods</a></li>
|
|
<li><a href="#Events">Events</a></li>
|
|
<li><a href="#Download">Download</a></li>
|
|
<li><a href="#Compatibility">Compatibility</a></li>
|
|
<li><a href="#Support">Support</a></li>
|
|
<li><a href="#Credits">Credits</a></li>
|
|
</ol>
|
|
|
|
<a id="Introduction"></a>
|
|
<h1>Introduction</h1>
|
|
<p>
|
|
tablesorter is a <a class="external" href="http://jquery.com">jQuery</a> 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:
|
|
</p>
|
|
|
|
<ul>
|
|
<li>Multi-column sorting</li>
|
|
<li>Multi-tbody sorting - see the <a href="#options">options</a> table below</li>
|
|
<li>Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. <a href="example-parsers.html">Add your own easily</a></li>
|
|
<li>Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria)</li>
|
|
<li>Extensibility via <a href="example-widgets.html">widget system</a></li>
|
|
<li>Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+</li>
|
|
<li>Small code size</li>
|
|
</ul>
|
|
|
|
<a id="Demo"></a>
|
|
<h1>Demo</h1>
|
|
|
|
<table id="tablesorter-demo" class="tablesorter">
|
|
<thead>
|
|
<tr>
|
|
<th>Account #</th>
|
|
<th>First Name</th>
|
|
<th>Last Name</th>
|
|
<th>Age</th>
|
|
<th>Total</th>
|
|
<th>Discount</th>
|
|
<th>Difference</th>
|
|
<th>Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>A42b</td>
|
|
<td>Peter</td>
|
|
<td>Parker</td>
|
|
<td>28</td>
|
|
<td>$9.99</td>
|
|
<td>20.9%</td>
|
|
<td>+12.1</td>
|
|
<td>Jul 6, 2006 8:14 AM</td>
|
|
</tr>
|
|
<tr>
|
|
<td>A255</td>
|
|
<td>John</td>
|
|
<td>Hood</td>
|
|
<td>33</td>
|
|
<td>$19.99</td>
|
|
<td>25%</td>
|
|
<td>+12</td>
|
|
<td>Dec 10, 2002 5:14 AM</td>
|
|
</tr>
|
|
<tr>
|
|
<td>A33</td>
|
|
<td>Clark</td>
|
|
<td>Kent</td>
|
|
<td>18</td>
|
|
<td>$15.89</td>
|
|
<td>44%</td>
|
|
<td>-26</td>
|
|
<td>Jan 12, 2003 11:14 AM</td>
|
|
</tr>
|
|
<tr>
|
|
<td>A1</td>
|
|
<td>Bruce</td>
|
|
<td>Almighty</td>
|
|
<td>45</td>
|
|
<td>$153.19</td>
|
|
<td>44.7%</td>
|
|
<td>+77</td>
|
|
<td>Jan 18, 2001 9:12 AM</td>
|
|
</tr>
|
|
<tr>
|
|
<td>A102</td>
|
|
<td>Bruce</td>
|
|
<td>Evans</td>
|
|
<td>22</td>
|
|
<td>$13.19</td>
|
|
<td>11%</td>
|
|
<td>-100.9</td>
|
|
<td>Jan 18, 2007 9:12 AM</td>
|
|
</tr>
|
|
<tr>
|
|
<td>A42a</td>
|
|
<td>Bruce</td>
|
|
<td>Evans</td>
|
|
<td>22</td>
|
|
<td>$13.19</td>
|
|
<td>11%</td>
|
|
<td>0</td>
|
|
<td>Jan 18, 2007 9:12 AM</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<p class="tip">
|
|
<em>TIP!</em> Sort multiple columns simultaneously by holding down the shift key and clicking a second, third or even fourth column header!
|
|
</p>
|
|
|
|
|
|
<a id="Getting-Started"></a>
|
|
<h1>Getting started</h1>
|
|
<p>
|
|
To use the tablesorter plugin, include the <a class="external" href="http://jquery.com">jQuery</a>
|
|
library and the tablesorter plugin inside the <code><head></code> tag
|
|
of your HTML document:
|
|
</p>
|
|
|
|
<pre class="prettyprint lang-html"><!-- 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>
|
|
</pre>
|
|
|
|
<p>tablesorter works on standard HTML tables. You must include THEAD and TBODY tags:</p>
|
|
|
|
<pre class="prettyprint lang-html"><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></pre>
|
|
|
|
<p>Start by telling tablesorter to sort your table when the document is loaded:</p>
|
|
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("#myTable").tablesorter();
|
|
});</pre>
|
|
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
|
|
});</pre>
|
|
|
|
<p class="tip">
|
|
<em>NOTE!</em> tablesorter will auto-detect most data types including numbers, dates, ip-adresses for more information see <a href="#Examples">Examples</a>
|
|
</p>
|
|
|
|
<a id="Examples"></a>
|
|
<h1>Examples</h1>
|
|
<p>
|
|
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.
|
|
</p>
|
|
|
|
<div class="box">
|
|
<h3>Basic</h3>
|
|
<h4>Sorting</h4>
|
|
<ul>
|
|
<li><a href="example-option-sort-list.html">Set an initial sorting order using options</a></li>
|
|
<li><a href="example-trigger-sort.html">Sort table using a link outside the table</a></li>
|
|
<li><a href="example-option-sort-force.html">Force a default sorting order</a></li>
|
|
<li><a href="example-option-sort-append.html">Append a sort to the selected sorting order</a></li>
|
|
<li><a href="example-child-rows.html">Child rows; how to add rows that sort with their parent row</a></li>
|
|
<li><a href="example-child-rows-filtered.html">Child rows + filter widget; how they work together</a></li>
|
|
<li><a href="example-option-sort-order.html">Direction of initial sort</a></li>
|
|
<li><a href="example-options-headers.html">Disable sort</a></li>
|
|
<li><a href="example-options-headers-locked.html">Lock sort order</a></li>
|
|
<li><a href="example-options-headers-order.html">Set initial sort order</a></li>
|
|
<li><a href="example-option-sortreset-sortrestart.html">Using sortReset & sortRestart options</a></li>
|
|
<li><a href="example-method-sortreset.html">Resetting the entire table sort</a> (sortReset method) (v2.4.7)</li>
|
|
<li><a href="example-option-selectorsort.html">Using selectorSort option</a> (v2.4)</li>
|
|
<li><a href="example-option-sort-empty.html">Sorting empty cells</a> (v2.1.11)</li>
|
|
<li><a href="example-option-sort-key.html">Change the default multi-sorting key</a></li>
|
|
<li><a href="example-option-custom-sort.html">Custom sort script</a> (v2.2)</li>
|
|
<li><a href="example-locale-sort.html">Sorting Accented Characters</a> (v2.24; <a href="https://github.com/Mottie/tablesorter/wiki/Language">languages</a>)</li>
|
|
<li><a href="example-multiple-tbodies.html">Sorting with Multiple Tbodies</a> (v2.2)</li>
|
|
<li><a href="example-header-column-span.html">Sorting Across Multiple Columns</a> (v2.3)</li>
|
|
<li><a href="example-option-show-processing.html">Show a processing icon during sorting/filtering</a> (v2.4)</li>
|
|
</ul>
|
|
|
|
<h4>Parsers / Extracting Content</h4>
|
|
<ul>
|
|
<li><a href="example-option-digits.html">Dealing with digits!</a></li>
|
|
<li><a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> (v2.0.10)</li>
|
|
<li><a href="example-parsers-class-name.html">Disable or set the column parser using class names</a> (v2.0.11)</li>
|
|
<li><a href="example-parsers-jquery-data.html">Disable or set the column parser using jQuery Data</a> (v2.3)</li>
|
|
<li><a href="example-option-date-format.html">Changing the date format</a> (v2.0.23)</li>
|
|
<li><a href="example-parsers.html">Parser, writing your own</a></li>
|
|
<li><a href="example-parsers-advanced.html">Parser, writing your own, advanced use</a> (v2.1)</li>
|
|
<li><a href="example-option-text-extraction.html">Dealing with markup inside cells (textExtraction function)</a></li>
|
|
</ul>
|
|
|
|
<h4>Widgets / Plugins</h4>
|
|
<ul>
|
|
<li><a href="example-apply-widget.html">Applying widgets</a></li>
|
|
<li><a href="example-widget-columns.html">Columns widget</a> (v2.0.17)</li>
|
|
<li><a href="example-widget-filter.html">Filter widget</a> (v2.0.18)</li>
|
|
<li><a href="example-widget-filter-custom.html">Filter widget, custom</a> (v2.3.6)</li>
|
|
<li><a href="example-widget-ui-theme.html">UITheme widget - jQuery UI theme</a> (v2.0.9; Modified v2.4)</li>
|
|
<li><a href="example-widget-bootstrap-theme.html">UITheme widget - Bootstrap</a> (v2.4)</li>
|
|
<li><a href="example-widget-resizable.html">Resizable Columns widget</a> (v2.0.23.1; <span class="tip"><em>Modified</em></span> v2.7.4)</li>
|
|
<li><a href="example-widget-savesort.html">Save sort widget</a> (v2.0.27)</li>
|
|
<li><a href="example-widget-sticky-header.html">Sticky header widget</a> (v2.0.21.1)</li>
|
|
<li><a href="example-widget-zebra.html">Zebra stripe widget</a></li>
|
|
<li><a href="example-widgets.html">Widgets, writing your own</a></li>
|
|
<li><a href="example-pager.html">Pager plugin</a></li>
|
|
<li><a href="example-pager-ajax.html">Pager plugin - ajax</a> (v2.1)</li>
|
|
<li><a href="example-pager-filtered.html">Pager plugin + filter widget</a> (v2.4)</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="box">
|
|
<h3>Advanced</h3>
|
|
<h4>Adding / Removing Content</h4>
|
|
<ul>
|
|
<li><a href="example-empty-table.html">Initializing tablesorter on a empty table</a></li>
|
|
<li><a href="example-ajax.html">Appending table data with ajax</a></li>
|
|
<li><a href="example-add-rows.html">Adding a table row</a> (v2.0.16)</li>
|
|
<li><a href="example-update-cell.html">Update the table after cell content has changed</a></li>
|
|
<li><a href="example-pager.html">Pager plugin</a> - examples of how to add and remove rows</li>
|
|
</ul>
|
|
|
|
<h4>Change Header Style</h4>
|
|
<ul>
|
|
<li><a href="example-widget-ui-theme.html">UITheme widget</a> (v2.0.9)</li>
|
|
<li><a href="example-option-render-header.html">Modifying the Header during rendering.</a></li>
|
|
<li><a href="example-option-render-template.html">Modifying the Header using a template</a>. <span class="tip"><em>New!</em></span> v2.7</li>
|
|
</ul>
|
|
|
|
<br>
|
|
|
|
<h3>Other</h3>
|
|
<h4>Options & Events</h4>
|
|
<ul>
|
|
<li><a href="example-triggers.html">Triggers sortEnd and sortStart (Displaying sorting progress)</a></li>
|
|
<li><a href="example-extending-defaults.html">Extending default options</a></li>
|
|
<li><a href="example-option-debug.html">Enabling debug mode</a></li>
|
|
</ul>
|
|
|
|
<h4>Playgrounds & Other demos</h4>
|
|
<ul>
|
|
<li><a href="http://jsfiddle.net/Mottie/4mVfu/">tablesorter basic demo</a> (includes widgets)</li>
|
|
<li><a href="http://jsfiddle.net/Mottie/abkNM/325/">tablesorter basic demo using jQuery UI theme</a></li>
|
|
<li><a href="http://jsfiddle.net/Mottie/4mVfu/1/">tablesorter basic demo with pager plugin</a></li>
|
|
<li><a href="http://codepen.io/Mottie/pen/eqBbn">tableSorter LESS theme; modify the colors dynamically in this LESS theme demo!</a></li>
|
|
<li><a href="https://github.com/Mottie/tablesorter/wiki">More demos - added to wiki pages</a></li>
|
|
</ul>
|
|
|
|
<h4 id="metadata">Metadata - setting inline options</h4>
|
|
<ul>
|
|
<li>*Note* you can use class names (version 2.0.11+, <a href="example-parsers-class-name.html">demo</a>), or jQuery data (version 2.3+, <a href="example-parsers-jquery-data.html">demo</a>) instead of meta data</li>
|
|
<li><a href="example-meta-sort-list.html">Set a initial sorting order using metadata.</a></li>
|
|
<li><a href="example-meta-headers.html">Disable header using metadata</a></li>
|
|
<li><a href="example-meta-parsers.html">Setting column parser using metadata</a></li>
|
|
</ul>
|
|
</div>
|
|
<br class="clear">
|
|
|
|
<a id="Configuration"></a>
|
|
<h1>Configuration</h1>
|
|
|
|
<div class="tip">
|
|
<p></p>
|
|
tablesorter has many options you can pass in at initialization to achieve different effects<br>
|
|
<em>TIP!</em> Click on the link in the property column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
|
|
</div>
|
|
|
|
<table id="options" class="tablesorter options">
|
|
<thead>
|
|
<tr>
|
|
<th class="property">Property</th>
|
|
<th class="type">Type</th>
|
|
<th class="defaults">Default</th>
|
|
<th class="descrip">Description</th>
|
|
<th class="examples">Link</th>
|
|
</tr>
|
|
</thead>
|
|
<tfoot>
|
|
<tr>
|
|
<th class="property">Property</th>
|
|
<th class="type">Type</th>
|
|
<th class="defaults">Default</th>
|
|
<th class="descrip">Description</th>
|
|
<th class="examples">Link</th>
|
|
</tr>
|
|
</tfoot>
|
|
<tbody>
|
|
|
|
<tr id="cancelselection">
|
|
<td><span class="permalink">cancelSelection</span></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>Indicates if tablesorter should disable selection of text in the table header (TH). Makes header behave more like a button.</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="cssasc">
|
|
<td><a href="#" class="toggle2">cssAsc</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-headerAsc"</td>
|
|
<td>The CSS style used to style the header when sorting ascending. Default value <span class="tip"><em>Changed!</em></span> v2.5.
|
|
<div class="collapsible">
|
|
Example from the blue theme:
|
|
<pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-headerAsc {
|
|
background-color: #9fbfdf;
|
|
background-image: url(black-asc.gif);
|
|
}</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="csschildrow">
|
|
<td><a class="toggle" href="#">cssChildRow</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-childRow"</td>
|
|
<td>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" (Changed in v2.4).</td>
|
|
<td>Ex:<a href="example-child-rows.html">1</a> <a href="example-child-rows-filtered.html">2</a></td>
|
|
</tr>
|
|
<tr class="tablesorter-childRow">
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td>This is an entirely new row, but attached to the row above while sorting<br>
|
|
cssChildRow Example HTML:
|
|
<pre class="prettyprint lang-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>
|
|
</pre>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="cssdesc">
|
|
<td><a href="#" class="toggle2">cssDesc</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-headerDesc"</td>
|
|
<td>The CSS style used to style the header when sorting descending. Default value <span class="tip"><em>Changed!</em></span> v2.5.
|
|
<div class="collapsible">
|
|
Example from the blue theme:
|
|
<pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-headerDesc {
|
|
background-color: #8cb3d9;
|
|
background-image: url(black-desc.gif);
|
|
}</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="cssheader">
|
|
<td><a href="#" class="toggle2">cssHeader</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-header"</td>
|
|
<td>The CSS style used to style the header in its unsorted state.
|
|
<div class="collapsible">
|
|
Example from the blue theme:
|
|
<pre class="prettyprint lang-css">.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;
|
|
}</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="cssheaderrow">
|
|
<td><a href="#" class="toggle2">cssHeaderRow</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-headerRow"</td>
|
|
<td>The CSS style used to style the header row (v2.4).
|
|
<div class="collapsible">
|
|
Previously 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 targetted in the plugin.
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="cssicon">
|
|
<td><a href="#" class="toggle2">cssIcon</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-icon"</td>
|
|
<td>The CSS style used to style the header cell icon. <span class="tip"><em>Modified!</em></span> v2.7.
|
|
<div class="collapsible"><br>
|
|
As of 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 <code>cssIcon</code> option to an empty string.<br>
|
|
<br>
|
|
In v2.7, the icon will only be added to the header if <strong>both</strong> the <code>cssIcon</code> option is set AND the <code>headerTemplate</code> option includes the icon tag (<code>{icon}</code>).
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="cssprocessing">
|
|
<td><span class="permalink">cssProcessing</span></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-processing"</td>
|
|
<td>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 <a href="#showprocessing"><code>showProcessing</code></a> option to <code>false</code> (v2.4).</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="cssinfoblock">
|
|
<td><a href="#" class="toggle2">cssInfoBlock</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-infoOnly"</td>
|
|
<td>All tbodies with this class name will not have its contents sorted. (v2.2).
|
|
<div class="collapsible">
|
|
<br>
|
|
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.
|
|
<pre class="prettyprint lang-html"><tbody class="tablesorter-infoOnly">
|
|
<tr>
|
|
<th>The contents of this tbody</th>
|
|
</tr>
|
|
<tr>
|
|
<td>will not be sorted</td>
|
|
</tr>
|
|
</tbody></pre>
|
|
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.
|
|
<br>
|
|
<p class="tip">
|
|
<em>NOTE!</em> 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.
|
|
</p>
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="dateformat">
|
|
<td><a href="#" class="toggle2">dateFormat</a></td>
|
|
<td>String</td>
|
|
<td>"mmddyyyy"</td>
|
|
<td>Set the date format. Here are the available options. (Modified v2.0.23).
|
|
<div class="collapsible">
|
|
<ul>
|
|
<li><code>"mmddyyyy"</code> (default)</li>
|
|
<li><code>"ddmmyyyy"</code></li>
|
|
<li><code>"yyyymmdd"</code></li>
|
|
</ul>
|
|
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!<br>
|
|
<br>
|
|
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 <a href="example-option-date-format.html">the demo page</a> to see it working.
|
|
<pre class="prettyprint lang-javascript">$(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
|
|
}
|
|
|
|
});
|
|
});</pre>
|
|
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (Modified v2.3.1):
|
|
<ul>
|
|
<li>jQuery data <code>data-dateFormat="mmddyyyy"</code>.</li>
|
|
<li>metadata <code>class="{ dateFormat: 'mmddyyyy'}"</code>. This requires the metadata plugin.</li>
|
|
<li>headers option <code>headers : { 0 : { dateFormat : 'mmddyyyy' } }</code>.</li>
|
|
<li>header class name <code>class="dateFormat-mmddyyyy"</code>.</li>
|
|
<li>Overall <code>dateFormat</code> option.</li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-date-format.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="debug">
|
|
<td><span class="permalink">debug</span></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Boolean flag indicating if tablesorter should display debuging information useful for development.
|
|
</td>
|
|
<td><a href="example-option-debug.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="delayinit">
|
|
<td><span class="permalink">delayInit</span></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
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.
|
|
</td>
|
|
<td><a href="example-option-debug.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="emptyto">
|
|
<td><a href="#" class="toggle2">emptyTo</a></td>
|
|
<td>String</td>
|
|
<td>"bottom"</td>
|
|
<td>
|
|
Boolean flag indicating how tablesorter should deal with empty table cells. (Modified v2.1.16).
|
|
<div class="collapsible">
|
|
<ul>
|
|
<li><code>bottom</code> - sort empty table cells to the bottom.</li>
|
|
<li><code>top</code> - sort empty table cells to the top.</li>
|
|
<li><code>none</code> or <code>zero</code> - sort empty table cells as if the cell has the value equal to zero.</li>
|
|
</ul>
|
|
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
|
|
<ul>
|
|
<li>jQuery data <code>data-empty="top"</code>.</li>
|
|
<li>metadata <code>class="{ empty: 'top'}"</code>. This requires the metadata plugin.</li>
|
|
<li>headers option <code>headers : { 0 : { empty : 'top' } }</code>.</li>
|
|
<li>header class name <code>class="empty-top"</code>.</li>
|
|
<li>Overall <code>emptyTo</code> option.</li>
|
|
</ul>
|
|
<code>emptyToBottom</code> option was added in v2.1.11, then replaced by the <code>emptyTo</code> option in v2.1.16.
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-sort-empty.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="headerlist">
|
|
<td><span class="permalink">headerList</span></td>
|
|
<td>Array</td>
|
|
<td>[ ] (empty array)</td>
|
|
<td>Internal list of each header element as selected using jQuery selectors in the <a href="#selectorheaders"><code>selectorHeaders</code></a> option. Not really useful for normal usage.</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="headers">
|
|
<td><a href="#" class="toggle2">headers</a></td>
|
|
<td>Object</td>
|
|
<td>null</td>
|
|
<td>
|
|
An object of instructions for per-column controls in the format: <code>headers: { 0: { option: setting }, ... }</code>
|
|
<div class="collapsible">
|
|
<br>
|
|
For example, to disable sorting on the first two columns of a table: <code>headers: { 0: { sorter: false}, 1: {sorter: false} }</code>.<br>
|
|
<br>
|
|
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 <a href="#parsers">default parsers</a> here or <a href="example-parsers.html">write your own</a>.
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
headers: {
|
|
|
|
// See example - Disable first column
|
|
0: { sorter: false },
|
|
|
|
// See example 2: Sort column numerically & treat any text as if its value is:
|
|
1: { sorter: "digit", empty: "top" }, // zero; sort empty cells to the top
|
|
2: { sorter: "digit", string: "max" }, // maximum positive value
|
|
3: { sorter: "digit", string: "min" }, // maximum negative value
|
|
|
|
// Sort the fifth column by date & set the format
|
|
4: { sorter: "shortDate", dateFormat: "yyyymmdd" }, // year first format
|
|
|
|
// See example 3: lock the sort order
|
|
// this option will not work if added as metadata
|
|
5: { lockedOrder: "asc" },
|
|
|
|
// See Example 4: Initial sort order direction of seventh column
|
|
6: { sortInitialOrder: "desc" },
|
|
|
|
// Set filter widget options for this column
|
|
// See the "Applying the filter widget" demo
|
|
7: { filter: false }, // disable filter widget for this column
|
|
8: { filter: "parsed" }, // use parsed data for this column in the filter search
|
|
|
|
// Set resizable widget options for this column
|
|
9: { resizable: false } // prevent resizing of column 9
|
|
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td>
|
|
Ex:<a href="example-options-headers.html">1</a>
|
|
<a href="example-options-headers-digits-strings.html">2</a>
|
|
<a href="example-options-headers-locked.html">3</a>
|
|
<a href="example-options-headers-order.html">4</a>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr id="headertemplate">
|
|
<td><a href="#" class="toggle2">headerTemplate</a></td>
|
|
<td>String</td>
|
|
<td>'{content} {icon}'</td>
|
|
<td>This is a template string which allows adding additional content to the header while it is being built. <span class="tip"><em>New!</em></span> v2.7.
|
|
<div class="collapsible"><br>
|
|
This template string has two default tags: <code>{content}</code> and <code>{icon}</code>.<br>
|
|
<code>{content}</code> will be replaced by the current header HTML content.<br>
|
|
<code>{icon}</code> will be replaced by <code><i class="tablesorter-icon"></i></code>, but only if a class name is defined in the <code>cssIcon</code> option.<br>
|
|
<br>
|
|
This template string may also contain HTML, e.g (<code>'<em>{content}</em>'</code>)<br>
|
|
<br>
|
|
After the template string is built, the <code>onRenderTemplate</code> function is called to allow further manipulation. Please read more about this <a href="#onrendertemplate"><code>onRenderTemplate</code> function</a> and/or check out the example (link to the right).
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-render-template.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="ignorecase">
|
|
<td><span class="permalink">ignoreCase</span></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>When true, text sorting will ignore the character case. If false, upper case characters will sort before lower case. (v2.2).</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="initwidgets">
|
|
<td><a href="#" class="toggle2">initWidgets</a></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>Apply widgets after table initializes (v2.3.5).
|
|
<div class="collapsible">
|
|
When true, all widgets set by the <code>widgets</code> option will apply after tablesorter has initialized, this is the normal behavior.<br>
|
|
<br>
|
|
If false, the each widget set by the <code>widgets</code> 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.<br>
|
|
<br>
|
|
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.
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="onrenderheader">
|
|
<td><a href="#" class="toggle2">onRenderHeader</a></td>
|
|
<td>Function</td>
|
|
<td>null</td>
|
|
<td>
|
|
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.
|
|
<div class="collapsible">
|
|
<br>
|
|
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 (<a href="http://www.pengoworks.com/workshop/jquery/tablesorter/tablesorter.htm">source</a>).
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
headerTemplate: '{content}',
|
|
onRenderHeader: function (){
|
|
$(this).find('div').addClass('roundedCorners');
|
|
}
|
|
});
|
|
});</pre>and you'll end up with this HTML (only the thead is shown)<pre class="prettyprint lang-html"><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></pre>
|
|
<small>* 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.</small>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-render-header.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="onrendertemplate">
|
|
<td><a href="#" class="toggle2">onRenderTemplate</a></td>
|
|
<td>Function</td>
|
|
<td>null</td>
|
|
<td>
|
|
This function is called after the template string has been built, but before the template string is applied to the header and before the <code>onRenderHeader</code> function is called. <span class="tip"><em>New!</em></span> v2.7.
|
|
<div class="collapsible">
|
|
<br>
|
|
The <code>onRenderTemplate</code> function receives a column index and template string parameters. The template string, from the <a href="#headertemplate"><code>headerTemplate</code> option</a>, will already have the <code>{icon}</code> and <code>{content}</code> tags replaced; it's just a string of formatted HTML. When done manipulating this string, return it. Here is an example:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
headerTemplate: '{icon}{content}',
|
|
onRenderTemplate: function (index, template){
|
|
return '<em>' + (index + 1) + ':</em> ' + template;
|
|
}
|
|
});
|
|
});</pre>The <code>template</code> parameter can be manipulated as a string, or if you prefer, turn it into a jQuery object (<code>var $t = $(template)</code>) to find and replace content as desired. Just make sure you return a string (<code>return $t.html()</code>)<br>
|
|
<br>
|
|
From the example function above, you'll end up with something similar to this HTML (only the thead is shown)<pre class="prettyprint lang-html"><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></pre>
|
|
<small>* Note: If the <code>cssIcon</code> option is an empty string, the <code>{icon}</code> tag will also become an empty string.</small>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-render-template.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="parsers">
|
|
<td><a href="#" class="toggle2">parsers</a></td>
|
|
<td>Object</td>
|
|
<td>{ }</td>
|
|
<td>Internal list of all of the parsers. Here is a complete list of default parsers:
|
|
<div class="collapsible">
|
|
<br>
|
|
<table class="info"><tbody>
|
|
<tr><th><code>sorter: false</code></th><td>disable sort for this column.</td></tr>
|
|
<tr><th><code>sorter: "text"</code></th><td>Sort alpha-numerically.</td></tr>
|
|
<tr><th><code>sorter: "digit"</code></th><td>Sort numerically.</td></tr>
|
|
<tr><th><code>sorter: "currency"</code></th><td>Sort by currency value (supports "£$€¤¥¢").</td></tr>
|
|
<tr><th><code>sorter: "ipAddress"</code></th><td>Sort by IP Address.</td></tr>
|
|
<tr><th><code>sorter: "url"</code></th><td>Sort by url.</td></tr>
|
|
<tr><th><code>sorter: "isoDate"</code></th><td>Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD; these formats can be followed by a time).</td></tr>
|
|
<tr><th><code>sorter: "percent"</code></th><td>Sort by percent.</td></tr>
|
|
<tr><th><code>sorter: "usLongDate"</code></th><td>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)).</td></tr>
|
|
<tr><th><code>sorter: "shortDate"</code></th><td>Sort by a shorten date (see <a href="#dateformat"><code>dateFormat</code></a>).</td></tr>
|
|
<tr><th><code>sorter: "time"</code></th><td>Sort by time (23:59 or 12:59 pm).</td></tr>
|
|
<tr><th><code>sorter: "metadata"</code></th><td>Sort by the sorter value in the metadata - requires the metadata plugin.</td></tr>
|
|
</tbody></table><br>
|
|
Check out the <a href="#headers"><code>headers</code></a> option to see how to use these parsers in your table (example #1).<br>Or add a header class name using "sorter-" plus the parser name (example #2), this includes custom parsers (example #3).
|
|
</div>
|
|
</td>
|
|
<td>
|
|
Ex:<a href="example-options-headers-digits-strings.html">1</a>
|
|
<a href="example-parsers-class-name.html">2</a>
|
|
<a href="example-parsers.html">3</a>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr id="selectorheaders">
|
|
<td><a href="#" class="toggle2">selectorHeaders</a></td>
|
|
<td>String</td>
|
|
<td>"> thead th, > thead td"</td>
|
|
<td>jQuery selectors used to find cells in the header.
|
|
<div class="collapsible">
|
|
You can change this, but the table will still need the required thead and tbody before this plugin will work properly.
|
|
<br>Added <code>></code> to the selector in v2.3 to prevent targetting nested table headers. It was modified again in v2.4 to include <code>td</code> cells within the thead.
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="selectorremove">
|
|
<td><a href="#" class="toggle2">selectorRemove</a></td>
|
|
<td>String</td>
|
|
<td>"tr.remove-me"</td>
|
|
<td>This CSS class name can be applied to all rows that are to be removed prior to triggering a table update. (v2.1).
|
|
<div class="collapsible">
|
|
<br>
|
|
It was necessary to add this option because some widgets add table rows for styling (see the <a href="example-widgets.html">writing custom widgets demo</a>) and if a table update is triggered (<code>$('table').trigger('update');</code>) those added rows will automatically become incorporated into the table.
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="selectorsort">
|
|
<td><span class="permalink">selectorSort</span></td>
|
|
<td>String</td>
|
|
<td>"th, td"</td>
|
|
<td>jQuery selector of content within <a href="#selectorheaders"><code>selectorHeaders</code></a> that is clickable to trigger a sort (v2.4).</td>
|
|
<td><a href="example-option-selectorsort.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="serversidesorting">
|
|
<td><span class="permalink">serverSideSorting</span></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>Set to <code>true</code> if the server is performing the sorting. The ui and events will still be used (v2.5.3).</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="showprocessing">
|
|
<td><span class="permalink">showProcessing</span></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>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).</td>
|
|
<td><a href="example-option-show-processing.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortforce">
|
|
<td><a href="#" class="toggle2">sortForce</a></td>
|
|
<td>Array</td>
|
|
<td>null</td>
|
|
<td>Use to add an additional forced sort that is <strong>prepended</strong> to <a href="#sortlist"><code>sortList</code></a>.
|
|
<div class="collapsible">
|
|
<br>
|
|
For example, <code>sortForce: [[0,0]]</code> will sort the first column in ascending order. After the forced sort, the user selected column(s), or during initialzation, the sorting order defined in the sortList will follow. And lastly, the sort defined in the <a href="#sortappend"><code>sortAppend</code></a> option will be applied. More explicitly:<br>
|
|
<br>
|
|
There are three options to determine the sort order and this is the order of priority:
|
|
<ol>
|
|
<li><a href="#sortforce"><code>sortForce</code></a> forces the user to have this/these column(s) sorted first (null by default).</li>
|
|
<li><a href="#sortlist"><code>SortList</code></a> is the initial sort order of the columns.</li>
|
|
<li><a href="#sortappend"><code>SortAppend</code></a> is the default sort that is added to the end of the users sort selection (null by default).</li>
|
|
</ol>
|
|
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: <code>[[columnIndex, sortDirection], ... ]</code> where <code>columnIndex</code> is a zero-based index for your columns left-to-right and <code>sortDirection</code> is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: <code>[[0,0],[1,0]]</code>.
|
|
<pre class="prettyprint lang-javascript">$(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)
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-option-sort-force.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortlist">
|
|
<td><a href="#" class="toggle2">sortList</a></td>
|
|
<td>Array</td>
|
|
<td>null</td>
|
|
<td>Use to add an initial sort to the table.
|
|
<div class="collapsible">
|
|
<br>
|
|
The value contains an array of instructions for per-column sorting and direction in the format: <code>[[columnIndex, sortDirection], ... ]</code> 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: <code>[[0,0],[1,0]]</code>. Please see <a href="#sortforce"><code>sortForce</code></a> for more details on other sort order options.<br>
|
|
<br>
|
|
This option can also be set using jQuery data (v2.3.1) or metadata on the table:
|
|
<table class="info">
|
|
<tfoot>
|
|
<tr><td colspan="2"><strong>** Note</strong>: <code>data-sortlist</code> data is not supported in jQuery versions older than 1.4.</td></tr>
|
|
</tfoot>
|
|
<tbody>
|
|
<tr><th>jQuery data</th><td><code><table data-sortlist="[[0,0],[4,0]]"></code> <strong>**</strong></td></tr>
|
|
<tr><th>Meta data</th><td><code><table class="tablesorter {sortlist: [[0,0],[4,0]]}"></code></td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-sort-list.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortappend">
|
|
<td><a href="#" class="toggle2">sortAppend</a></td>
|
|
<td>Array</td>
|
|
<td>null</td>
|
|
<td>Use to add an additional forced sort that will be appended to the dynamic selections by the user.
|
|
<div class="collapsible">
|
|
<br>
|
|
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.<br>
|
|
<br>
|
|
The value contains an array of instructions for per-column sorting and direction in the format: <code>[[columnIndex, sortDirection], ... ]</code> where <code>columnIndex</code> 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: <code>[[0,0],[1,0]]</code>. Please see <a href="#sortforce"><code>sortForce</code></a> for more details on other sort order options.
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-sort-append.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortinitialorder">
|
|
<td><a href="#" class="toggle2">sortInitialOrder</a></td>
|
|
<td>String</td>
|
|
<td>"asc"</td>
|
|
<td>
|
|
The direction a column sorts when clicking the header for the first time. Valid arguments are <code>"asc"</code> for Ascending or <code>"desc"</code> for Descending.<br>
|
|
<div class="collapsible">
|
|
<br>
|
|
This order can also be set by desired column using the <a href="#headers"><code>headers</code></a> option (Added in v2.0.8).<br>
|
|
<br>
|
|
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (Modified v2.3.1):
|
|
<ul>
|
|
<li>jQuery data <code>data-sortInitialOrder="asc"</code>.</li>
|
|
<li>metadata <code>class="{ sortInitialOrder: 'asc'}"</code>. This requires the metadata plugin.</li>
|
|
<li>headers option <code>headers : { 0 : { sortInitialOrder : 'asc' } }</code>.</li>
|
|
<li>header class name <code>class="sortInitialOrder-asc"</code>.</li>
|
|
<li>Overall <code>sortInitialOrder</code> option.</li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<td>Ex:<a href="example-option-sort-order.html">1</a> <a href="example-options-headers-order.html">2</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortlocalecompare">
|
|
<td><a href="#" class="toggle2">sortLocaleCompare</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. (Modified v2.2).
|
|
<div class="collapsible">
|
|
<ul>
|
|
<li>This option no longer switches the sort to use the <code>String.localeCompare</code> method.</li>
|
|
<li>When this option is <code>true</code>, the text parsed from table cells will convert accented characters to their equivalent to allow the alphanumeric sort to properly sort.</li>
|
|
<li>If <code>false</code> (default), any accented characters are treated as their value in the standard unicode order.</li>
|
|
<li>The following characters are replaced for both upper and lower case (information obtained from <a href="http://sugarjs.com/sorting">sugar.js sorting equivalents</a> table):
|
|
<ul>
|
|
<li><code>áàâãä</code> replaced with <code>a</code></li>
|
|
<li><code>ç</code> replaced with <code>c</code></li>
|
|
<li><code>éèêë</code> replaced with <code>e</code></li>
|
|
<li><code>íìİîï</code> replaced with <code>i</code></li>
|
|
<li><code>óòôõö</code> replaced with <code>o</code></li>
|
|
<li><code>úùûü</code> replaced with <code>u</code></li>
|
|
<li><code>ß</code> replaced with <code>S</code></li>
|
|
</ul>
|
|
</li>
|
|
<li>Please see the example page for instrcutions on how to modify the above equivalency table.</li>
|
|
<li>If you would like to continuing using the <code>String.localeCompare</code> method, then set the <code>sortLocaleCompare</code> option to <code>false</code> and use the new <a href="#textsorter"><code>textSorter</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$('table').tablesorter({
|
|
textSorter: function(a,b) {
|
|
return a.localeCompare(b);
|
|
}
|
|
});</pre></li>
|
|
</ul>
|
|
<p class="tip">
|
|
<em>NOTE:</em> See the <a href="https://github.com/Mottie/tablesorter/wiki/Language">Language</a> wiki page for language specific examples and how to extend the character equivalent tables seen in the <a href="example-locale-sort.html">sortLocaleCompare demo</a>.
|
|
</p>
|
|
<del>Boolean flag indicating whenever to use javascript <code>String.localeCompare</code> method or not.<br>
|
|
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.</del>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-locale-sort.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortreset">
|
|
<td><a href="#" class="toggle2">sortReset</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Setting this option to <code>true</code> will allow you to click on the table header a third time to reset the sort direction. (v2.0.27).
|
|
<div class="collapsible">
|
|
<br>Don't confuse this option with the <a href="#sortreset-method"><code>sortReset</code> method</a>. This option only resets the column sort after a third click, while the method immediately resets the entire table sort.
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortResetKey">
|
|
<td>sortResetKey</td>
|
|
<td>String</td>
|
|
<td>"ctrlKey"</td>
|
|
<td>The key used to reset sorting on the entire table. Defaults to the control key. The other options are <code>"shiftKey"</code> or <code>"altKey"</code>. Reference: <a class="external" href="https://developer.mozilla.org/en/DOM/MouseEvent">https://developer.mozilla.org/en/DOM/MouseEvent</a></td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="sortrestart">
|
|
<td><span class="permalink">sortRestart</span></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Setting this option to <code>true</code> will start the sort with the <a href="#sortinitialorder"><code>sortInitialOrder</code></a> when clicking on a previously unsorted column. (v2.0.31).
|
|
</td>
|
|
<td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortmultisortkey">
|
|
<td><span class="permalink">sortMultiSortKey</span></td>
|
|
<td>String</td>
|
|
<td>"shiftKey"</td>
|
|
<td>The key used to select more than one column for multi-column sorting. Defaults to the shift key. The other options are <code>"ctrlKey"</code> or <code>"altKey"</code>. Reference: <a class="external" href="https://developer.mozilla.org/en/DOM/MouseEvent">https://developer.mozilla.org/en/DOM/MouseEvent</a></td>
|
|
<td><a href="example-option-sort-key.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="stringto">
|
|
<td><a href="#" class="toggle2">stringTo</a></td>
|
|
<td>String</td>
|
|
<td>"max"</td>
|
|
<td>
|
|
Boolean flag indicating how tablesorter should deal with text inside of numerically sorted columns. (v2.1.16).
|
|
<div class="collapsible"><br>
|
|
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:
|
|
<ul>
|
|
<li><code>"max"</code> will treat any text in that column as a value greater than the <em>max</em> (more positive) value. Renamed from "max+".</li>
|
|
<li><code>"min"</code> will treat any text in that column as a value greater than the <em>min</em> (more negative) value. Renamed from "max-".</li>
|
|
<li><code>"top"</code> will always sort the text to the top of the column.</li>
|
|
<li><code>"bottom"</code> will always sort the text to the bottom of the column.</li>
|
|
<li><code>"none"</code> or <code>"zero"</code> will treat the text as if it has a value of zero.</li>
|
|
</ul>
|
|
Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
|
|
<ul>
|
|
<li>jQuery data <code>data-string="top"</code>.</li>
|
|
<li>metadata <code>class="{ string: 'top'}"</code>. This requires the metadata plugin.</li>
|
|
<li>headers option <code>headers : { 0 : { string : 'top' } }</code>.</li>
|
|
<li>header class name <code>class="string-top"</code>.</li>
|
|
<li>Overall <code>stringTo</code> option.</li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-options-headers-digits-strings.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="tableClass">
|
|
<td><a href="#" class="toggle2">tableClass</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter"</td>
|
|
<td>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.
|
|
<div class="collapsible">
|
|
<br>Change this option if you are not using the default css, or if you are using a completely custom stylesheet.
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="theme">
|
|
<td><a href="#" class="toggle2">theme</a></td>
|
|
<td>String</td>
|
|
<td>"default"</td>
|
|
<td>This option will add a theme css class name to the table <code>"tablesorter-{theme}"</code> for styling (v2.4).
|
|
<div class="collapsible">
|
|
<br>When changing this theme option, make sure that the appropriate css theme file has also been loaded. Included theme files include:
|
|
<a href="themes.html" target="_blank" title="open themes in a new window">see all themes</a><br>
|
|
<iframe style="width:100%;height:300px;" src="themes.html"></iframe>
|
|
</div>
|
|
</td>
|
|
<td><a href="themes.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="textextraction">
|
|
<td><a href="#" class="toggle2">textExtraction</a></td>
|
|
<td>String Or Function</td>
|
|
<td>"simple"</td>
|
|
<td>Defines which method is used to extract data from a table cell for sorting.
|
|
The built-in option is <code>"simple"</code> which is the equivalent of doing this inside of the textExtraction function: <code>$(node).text();</code>.
|
|
<div class="collapsible">
|
|
<br>
|
|
You can customize the text extraction by writing your own text extraction function "myTextExtraction" which you define like:
|
|
<pre class="prettyprint lang-javascript">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 } );
|
|
});</pre>
|
|
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).
|
|
<p>Now if the text you are finding in the script above is say a number, then just include the <a href="#headers"><code>headers</code></a> 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.</p>
|
|
<p>Added <code>table</code> and <code>cellIndex</code> variables to the <code>textExtraction</code> function in version 2.1.2.</p>
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
textExtraction: {
|
|
1: function(node, table, cellIndex) {
|
|
return $(node).find("span:last").text();
|
|
}
|
|
},
|
|
headers: {
|
|
1: { sorter : "digit" }
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-option-text-extraction.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="textsorter">
|
|
<td><a href="#" class="toggle2">textSorter</a></td>
|
|
<td>Function</td>
|
|
<td>null</td>
|
|
<td>
|
|
Replace the default sorting algorithm with a custom one using this option.
|
|
<div class="collapsible">
|
|
<br>
|
|
Include a script like <a href="https://github.com/overset/javascript-natural-sort">naturalSort.js</a> as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
textSorter : naturalSort
|
|
});
|
|
});</pre>
|
|
or use the localeCompare sort
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
textSorter: function(a,b) {
|
|
return a.localeCompare(b);
|
|
}
|
|
});
|
|
});</pre>There's no need to worry about reverse sorting, it's taken care of by the plugin.
|
|
</div>
|
|
</td>
|
|
<td><a href="example-option-custom-sort.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="usnumberformat">
|
|
<td><a href="#" class="toggle2">usNumberFormat</a></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>
|
|
Indicates how tablesorter should deal with a numerical format: (v2.1.3).
|
|
<div class="collapsible">
|
|
<table class="info"><tbody>
|
|
<tr>
|
|
<th><code>true</code></th>
|
|
<td class="right">U.S.</td>
|
|
<td><code>1,234,567.89</code></td>
|
|
</tr>
|
|
<tr>
|
|
<th><code>false</code></th>
|
|
<td class="right">German:<br>French:</td>
|
|
<td><code>1.234.567,89</code><br><code>1 234 567,89</code></td>
|
|
</tr>
|
|
</tbody></table>
|
|
</div>
|
|
</td>
|
|
<td><a href="../index.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widgets">
|
|
<td><span class="permalink">widgets</span></td>
|
|
<td>Array</td>
|
|
<td>[ ] (empty array)</td>
|
|
<td>
|
|
Initialize widgets using this option ( e.g. <code>widgets : ['zebra']</code>, or custom widgets <code>widgets: ['zebra', 'myCustomWidget'];</code>, see <a href="example-widgets.html">this demo</a> on how to write your own custom widget ).
|
|
</td>
|
|
<td><a href="example-widget-zebra.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widthfixed">
|
|
<td><a href="#" class="toggle2">widthFixed</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Indicates if tablesorter should apply fixed percentage-based widths to the table columns (modified v2.4).
|
|
<div class="collapsible">
|
|
Prior to v2.4, this option set pixel widths to added colgroups to fix the column widths. This is useful for the Pager companion.
|
|
<br>
|
|
<del>Requires the <a href="#Download-Addons">jQuery dimension plugin</a> to work.</del> This is now part of the jQuery core.
|
|
</div>
|
|
</td>
|
|
<td><a href="example-pager.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widgetoptions">
|
|
<td><a href="#" class="toggle2">widgetOptions</a></td>
|
|
<td>Object</td>
|
|
<td>{ }</td>
|
|
<td>
|
|
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).
|
|
<div class="collapsible">
|
|
<br>
|
|
Previously documented widget options <a href="#widgetzebra"><code>widgetZebra</code></a>, <a href="#widgetcolumns"><code>widgetColumns</code></a> and <a href="#widgetuitheme"><code>widgetUitheme</code></a> will be retained for backwards compatibility.<br>
|
|
<br>
|
|
Use the <a href="#widgetoptions"><code>widgetOptions</code></a> option as follows, please note that each option is followed by a comma (except the last one):
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
|
|
// initialize a bunch of widgets
|
|
widgets: ["zebra", "uitheme", "columns", "filter", "resizable", "stickyHeaders"],
|
|
|
|
widgetOptions: {
|
|
|
|
// *** columns widget ***
|
|
// change the default column class names
|
|
columns : [ "primary", "secondary", "tertiary" ],
|
|
// include thead when adding class names
|
|
columns_thead : true,
|
|
// include tfoot when adding class names
|
|
columns_tfoot : true,
|
|
|
|
// *** filter widget ***
|
|
// Include child rows content in the search
|
|
filter_childRows : false,
|
|
// show column filters
|
|
filter_columnFilters : true,
|
|
// css class applied to the filter row inputs/select
|
|
filter_cssFilter : "tablesorter-filter",
|
|
// add custom filter functions using this option.
|
|
filter_functions : null,
|
|
// if true, the filter row is hidden initially until hovered/focused.
|
|
filter_hideFilters : false,
|
|
// if true, make all searches case-insensitive.
|
|
filter_ignoreCase : true,
|
|
// jQuery selector string of an element used to reset the filters.
|
|
filter_reset : null,
|
|
// typing delay in milliseconds before starting a search.
|
|
filter_searchDelay : 300,
|
|
// if true, filter start from the beginning of the cell contents.
|
|
filter_startsWith : false,
|
|
// filter all data using parsed content.
|
|
filter_useParsedData : false,
|
|
// Set to true for server-side filtering
|
|
filter_serversideFiltering : false,
|
|
|
|
// *** stickyHeaders widget ***
|
|
// css class name applied to the sticky header
|
|
stickyHeaders : "tablesorter-stickyHeader",
|
|
|
|
// *** resizable widget ***
|
|
// if false, resized columns are not saved for next page reload
|
|
resizable : true,
|
|
|
|
// *** savesort widget ***
|
|
// if false, the sort will not be saved for next page reload
|
|
saveSort : true,
|
|
|
|
// *** uitheme widget ***
|
|
// include the name of the theme to use current options are
|
|
// "jui" (default) and "bootstrap"
|
|
uitheme : "jui",
|
|
|
|
// *** zebra widget ***
|
|
// class names to add, default is [ "even", "odd" ]
|
|
zebra : ["ui-widget-content even", "ui-state-default odd"]
|
|
|
|
}
|
|
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-zebra.html">Example</a></td>
|
|
</tr>
|
|
</tbody>
|
|
|
|
<!-- non-sorting tbody -->
|
|
<tbody id="deprecated" class="tablesorter-infoOnly">
|
|
<tr><th colspan="5">Deprecated Options</th></tr>
|
|
</tbody>
|
|
|
|
<tbody>
|
|
<tr id="widgetcolumns">
|
|
<td><a href="#" class="toggle2 deprecated">widgetColumns</a></td>
|
|
<td>Object with Array</td>
|
|
<td>{ css:[ "primary", "secondary", "tertiary" ] }</td>
|
|
<td>
|
|
This option is being <span class="deprecated">deprecated</span>!
|
|
It has been replaced by <a href="#widget-columns"><code>widgetOptions.columns</code></a>; but is still available for backwards compatibility.
|
|
<div class="collapsible">
|
|
<br>
|
|
When the column styling widget is initialized, it automatically applied the default class names of <code>"primary"</code> for the primary sort, <code>"secondary"</code> for the next sort, <code>"tertiary"</code> for the next sort, and so on (add more as needed)... (v2.0.17).
|
|
Use the <a href="#widgetcolumns"><code>widgetColumns</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["columns"], // initialize column styling of the table
|
|
widgetColumns: { css: ["primary", "secondary", "tertiary" ] }
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="widgetuitheme">
|
|
<td><a href="#" class="toggle2 deprecated">widgetUitheme</a></td>
|
|
<td>Object with Array</td>
|
|
<td>{ css: [ "ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n" ] }</td>
|
|
<td>
|
|
This option is being <span class="deprecated">deprecated</span>!
|
|
It has been replaced by <a href="#widget-uitheme"><code>widgetOptions.uitheme</code></a>; but is still available for backwards compatibility.
|
|
<div class="collapsible">
|
|
<br>
|
|
Used when the ui theme styling widget is initialized. It automatically applies the default class names of <code>"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code>"ui-icon-arrowthick-1-s"</code> for the descending sort and <code>"ui-icon-arrowthick-1-n"</code> for the ascending sort. (v2.0.9).
|
|
Find more jQuery UI class names by hovering over the Framework icons on this page: <a class="external" href="http://jqueryui.com/themeroller/">http://jqueryui.com/themeroller/</a><br>
|
|
<br>
|
|
Use the <a href="#widgetuitheme"><code>widgetUitheme</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(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)
|
|
]
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="widgetzebra">
|
|
<td><a href="#" class="toggle2 deprecated">widgetZebra</a></td>
|
|
<td>Object with Array</td>
|
|
<td>{ css: [ "even", "odd" ] }</td>
|
|
<td>
|
|
This option is being <span class="deprecated">deprecated</span>!
|
|
It has been replaced by <a href="#widget-zebra"><code>widgetOptions.zebra</code></a>; but is still available for backwards compatibility.
|
|
<div class="collapsible">
|
|
<br>
|
|
When the zebra striping widget is initialized, it automatically applied the default class names of <code>"even"</code> and <code>"odd"</code>.
|
|
Use the <a href="#widgetzebra"><code>widgetZebra</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["zebra"], // initialize zebra striping of the table
|
|
widgetZebra: { css: [ "normal-row", "alt-row" ] }
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<a id="Widget-options"></a>
|
|
<h1>Widget Options</h1>
|
|
|
|
<table class="tablesorter compatibility">
|
|
<thead>
|
|
<tr><th>Applied Order</th><th>Name</th><th>Requires jQuery</th><th>Limiting function</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr><td>6</td><td>columns</td><td>v1.2.6</td><td></td></tr>
|
|
<tr><td>5</td><td>filter</td><td>v1.4.3</td><td>1.4.3 (nextUntil)</td></tr>
|
|
<tr><td>8</td><td>pager</td><td>v1.2.6</td><td></td></tr>
|
|
<tr><td>4</td><td>resizable</td><td>v1.4.1*</td><td>1.4 (isEmptyObject); 1.4.1 (parseJSON)*</td></tr>
|
|
<tr><td>3</td><td>saveSort</td><td>v1.4.1</td><td>1.4.1 (parseJSON)*</td></tr>
|
|
<tr><td>2</td><td>stickyHeaders</td><td>v1.2.6</td><td></td></tr>
|
|
<tr><td>1</td><td>uitheme</td><td>v1.2.6</td><td></td></tr>
|
|
<tr><td>7</td><td>zebra</td><td>v1.2.6</td><td></td></tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<div class="tip">
|
|
<p></p>
|
|
tablesorter widgets have many options, and to better organize them, they now are grouped together inside of the <code>widgetOptions</code>. Thanks to thezoggy for putting together this jQuery-widget compatibility table, but please note:
|
|
<ul>
|
|
<li>The applied order will not change depending on the widgets applied, but the numbers will change.</li>
|
|
<li>The widgets are actually applied in reverse alphabetical order. This includes any custom widget names, so a custom widget named "zoom" will be the first applied widget. The only exception is the zebra widget which will always be the last widget applied.</li>
|
|
<li>The pager, being a plugin, is actually initialized after tablesorter has initialized and all selected widgets applied.</li>
|
|
<li>* The <code>saveSort</code> and <code>resizable</code> widgets use the <code>$.tablesorter.storage</code> function by default and thus need the <code>parseJSON</code> function which is available in jQuery 1.4.1+.</li>
|
|
</ul>
|
|
|
|
<br class="clear">
|
|
<em>TIP!</em> Click on the link in the property column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
|
|
</div>
|
|
|
|
<table id="widget-options" class="tablesorter options">
|
|
<thead>
|
|
<tr>
|
|
<th class="property">Property</th>
|
|
<th class="type">Type</th>
|
|
<th class="defaults">Default</th>
|
|
<th class="descrip">Description</th>
|
|
<th class="examples">Link</th>
|
|
</tr>
|
|
</thead>
|
|
<tfoot>
|
|
<tr>
|
|
<th class="property">Property</th>
|
|
<th class="type">Type</th>
|
|
<th class="defaults">Default</th>
|
|
<th class="descrip">Description</th>
|
|
<th class="examples">Link</th>
|
|
</tr>
|
|
</tfoot>
|
|
<tbody>
|
|
|
|
<tr id="widget-columns">
|
|
<td><a href="#" class="toggle2">columns</a></td>
|
|
<td>Array</td>
|
|
<td>[ "primary", "secondary", "tertiary" ]</td>
|
|
<td>
|
|
Columns widget: When the column styling widget is initialized, it automatically applied the default class names of <code>"primary"</code> for the primary sort, <code>"secondary"</code> for the next sort, <code>"tertiary"</code> for the next sort, and so on (add more as needed)... (Modified v2.1).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-columns"><code>"columns"</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["columns"], // initialize column styling of the table
|
|
widgetOptions : {
|
|
columns: [ "primary", "secondary", "tertiary" ]
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-columns.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-columns-thead">
|
|
<td><a href="#" class="toggle2">columns_thead</a></td>
|
|
<td>Array</td>
|
|
<td>true</td>
|
|
<td>
|
|
Columns widget: If true, the class names from the <code>columns</code> option will also be added to the table thead (v2.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-columns-thead"><code>"columns_thead"</code></a> option to add the column class names to the thead as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["columns"], // initialize column styling of the table
|
|
widgetOptions : {
|
|
columns_thead: true
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-columns.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-columns-tfoot">
|
|
<td><a href="#" class="toggle2">columns_tfoot</a></td>
|
|
<td>Array</td>
|
|
<td>true</td>
|
|
<td>
|
|
Columns widget: If true, the class names from the <code>columns</code> option will also be added to the table tfoot (v2.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-columns-tfoot"><code>"columns_tfoot"</code></a> option to add the column class names to the tfoot as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["columns"], // initialize column styling of the table
|
|
widgetOptions : {
|
|
columns_tfoot: true
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-columns.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-childrows">
|
|
<td><a href="#" class="toggle2">filter_childRows</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Filter widget: If there are child rows in the table (rows with class name from <a href="#csschildrow"><code>"cssChildRow"</code></a> option) and this option is <code>true</code> and a match is found anywhere in the child row, then it will make that row visible.
|
|
(Modified v2.1).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-childrows"><code>filter_childRows</code></a> option include child row text as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_childRows : true
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-columnFilters">
|
|
<td><a href="#" class="toggle2">filter_columnFilters</a></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>
|
|
Filter widget: If <code>true</code>, a filter will be added to the top of each table column (v2.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-columnFilters"><code>filter_columnFilters</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_columnFilters : true
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-cssfilter">
|
|
<td><a href="#" class="toggle2">filter_cssFilter</a></td>
|
|
<td>String</td>
|
|
<td>'tablesorter-filter'</td>
|
|
<td>
|
|
Filter widget: This is the class name applied to each input within the filter row. If you change it from the default class name of <code>"tablesorter-filter"</code> make sure you also update the css! (v2.1).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-cssfilter"><code>"tablesorter-filter"</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
// css class applied to the table row containing the filters & the inputs within that row
|
|
filter_cssFilter : "tablesorter-filter"
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-filter.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-functions">
|
|
<td><a href="#" class="toggle2">filter_functions</a></td>
|
|
<td>Object</td>
|
|
<td>null</td>
|
|
<td>
|
|
Filter widget: Customize the filter widget by adding a select dropdown with content, custom options or custom filter functions (v2.3.6).
|
|
<div class="collapsible">
|
|
Use the <a href="#widget-filter-functions"><code>"filter_functions"</code></a> option in three different ways:
|
|
<br>
|
|
<ul>
|
|
<li>
|
|
Make a sorted select dropdown list of all column contents. Repeated content will be combined.
|
|
<pre class="prettyprint lang-javascript">$(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
|
|
}
|
|
}
|
|
});
|
|
});</pre>
|
|
Alternately, instead of setting the column filter funtion to true, give the column header a class name of "filter-select". See the <a href="example-widget-filter-custom.html">demo</a>.<br><br>
|
|
</li>
|
|
<li>
|
|
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.
|
|
|
|
<h4>Regex example</h4>
|
|
<pre class="prettyprint lang-javascript">$(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
|
|
filter_functions: {
|
|
// Add these options to the select dropdown (regex example)
|
|
2 : {
|
|
"A - D" : function(e, n, f, i) { return /^[A-D]/.test(e); },
|
|
"E - H" : function(e, n, f, i) { return /^[E-H]/.test(e); },
|
|
"I - L" : function(e, n, f, i) { return /^[I-L]/.test(e); },
|
|
"M - P" : function(e, n, f, i) { return /^[M-P]/.test(e); },
|
|
"Q - T" : function(e, n, f, i) { return /^[Q-T]/.test(e); },
|
|
"U - X" : function(e, n, f, i) { return /^[U-X]/.test(e); },
|
|
"Y - Z" : function(e, n, f, i) { return /^[Y-Z]/.test(e); }
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});</pre>
|
|
<h4>Comparison example</h4>
|
|
<pre class="prettyprint lang-javascript">$(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
|
|
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) { return n < 10; },
|
|
"$10 - $100" : function(e, n, f, i) { return n >= 10 && n <=100; },
|
|
"> $100" : function(e, n, f, i) { return n > 100; }
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});</pre>
|
|
Note: if the <code>filter_ignoreCase</code> option is <code>true</code>, it DOES alter the normalized value (n) by making it all lower case.<br><br>
|
|
</li>
|
|
<li>
|
|
Make a custom filter for the column.
|
|
<pre class="prettyprint lang-javascript">$(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
|
|
filter_functions: {
|
|
// Exact match only
|
|
1 : function(e, n, f, i) {
|
|
return e === f;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});</pre>
|
|
Note: if the <code>filter_ignoreCase</code> option is <code>true</code>, it DOES alter the normalized value (n) by making it all lower case.<br><br>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-widget-filter-custom.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-hidefilters">
|
|
<td><a href="#" class="toggle2">filter_hideFilters</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Filter widget: Set this option to <code>true</code> to hide the filter row initially. The rows is revealed by hovering over the filter row or giving any filter input/select focus (v2.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-hidefilters"><code>filter_hideFilters</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_hideFilters : true
|
|
}
|
|
});
|
|
});</pre>You can change the style (thickness) of the hidden filter row in the tablesorter theme css. Look for <code>.tablesorter-filter-row</code> (revealed row) and <code>.tablesorter-filter-row.hideme</code> (for the hidden row) css definitions.</div>
|
|
</td>
|
|
<td><a href="example-widget-filter.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-ignorecase">
|
|
<td><a href="#" class="toggle2">filter_ignoreCase</a></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>
|
|
Filter widget: Set this option to <code>false</code> to make the column content search case-insensitive, so typing in "a" will not find "Albert". (v2.3.4)
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-ignorecase"><code>filter_ignorecase</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_ignoreCase : false
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-filter.html">Example</a></td>
|
|
</tr>
|
|
|
|
<!--
|
|
<tr id="widget-filter-quickSearch">
|
|
<td><a href="#" class="toggle2">filter_quickSearch</a></td>
|
|
<td>String</td>
|
|
<td>null</td>
|
|
<td>
|
|
This option is only available when using the advanced filter ("filter") contained in the <code>jquery.tablesorter.widgets.js</code> file. <span class="tip"><em>New! v2.4</em></span><br>
|
|
<div class="collapsible"><br>
|
|
To use it, point to the quick search input by adding the selector string to this option. For example, add this input (<code><input type="search"></code>) to the table header, or anywhere else on the page. That input will be used as a quick search filter for all table data when the input is targetted as follows:
|
|
<br>
|
|
Use the <a href="#widget-filter-quickSearch"><code>filter_quickSearch</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_quickSearch : '.quicksearch'
|
|
}
|
|
});
|
|
});</pre>
|
|
The quicksearch input:
|
|
<ul>
|
|
<li>applies to all columns and works with "AND" and "OR" operators (i.e. look for "!female AND >40"). See the updated <a href="http://mottie.github.com/tablesorter/docs/example-widget-filter-custom.html">custom filter widget demo</a>.</li>
|
|
<li>To exclude a specific column from the quick search, use any of the following settings, in order of priority:
|
|
<ul>
|
|
<li>jQuery data <code>data-filter="noquicksearch"</code>.</li>
|
|
<li>metadata <code>class="{ filter: 'noquicksearch'}"</code>. This requires the metadata plugin.</li>
|
|
<li>headers option <code>headers : { 0 : { filter : 'noquicksearch' } }</code>.</li>
|
|
<li>header class name <code>class="filter-noquicksearch"</code>.</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
Performing a quick search externally by triggering a search on the table as follows:
|
|
<pre class="prettyprint lang-javascript">$('table').trigger('search', [' AND h']);</pre>
|
|
<ul>
|
|
|
|
</div>
|
|
</td>
|
|
<td><a href="example-widget-filter-custom.html">Example</a></td>
|
|
</tr>
|
|
-->
|
|
|
|
<tr id="widget-filter-reset">
|
|
<td><a href="#" class="toggle2">filter_reset</a></td>
|
|
<td>String</td>
|
|
<td>null</td>
|
|
<td>
|
|
Filter widget: jQuery selector string of an element used to reset the filters (v2.4).
|
|
<div class="collapsible">
|
|
<p>
|
|
To use this option, point to a reset button or link using a jQuery selector. For example, add this button (<code><button class="reset">Reset</button></code>) 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):
|
|
</p>
|
|
Use the <a href="#widget-filter-reset"><code>filter_reset</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_reset : '.reset'
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-filter-custom.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-searchdelay">
|
|
<td><a href="#" class="toggle2">filter_searchDelay</a></td>
|
|
<td>Numeric</td>
|
|
<td>300</td>
|
|
<td>
|
|
Filter widget: Set this option to the number of milliseconds to delay the search. (v2.3.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-searchdelay"><code>filter_searchDelay</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_searchDelay : 500
|
|
}
|
|
});
|
|
});</pre>
|
|
|
|
If you want to want to initialize the filter without user input, target any one of the filters and trigger a "search".
|
|
|
|
<pre class="prettyprint lang-javascript">// 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);</pre>
|
|
|
|
In tablesorter v2.4+, the trigger can be applied directly to the table:
|
|
<pre class="prettyprint lang-javascript">// refresh the widget filter; no delay
|
|
$('table').trigger('search', false);</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-serversidefiltering">
|
|
<td><a href="#" class="toggle2">filter_serversideFiltering</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Filter widget: Set this option to <code>true</code> if filtering is performed on the server-side (v2.5.3).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-serversidefiltering"><code>filter_serversideFiltering</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_serversideFiltering : true
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-startswith">
|
|
<td><a href="#" class="toggle2">filter_startsWith</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Filter widget: Set this option to <code>true</code> 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).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-startswith"><code>filter_startsWith</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_startsWith : true
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-filter.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-filter-useParsedData">
|
|
<td><a href="#" class="toggle2">filter_useParsedData</a></td>
|
|
<td>Boolean</td>
|
|
<td>false</td>
|
|
<td>
|
|
Filter widget: If <code>true</code>, ALL filter searches will only use parsed data (v2.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-filter-useParsedData"><code>filter_useParsedData</code></a> option as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["filter"],
|
|
widgetOptions : {
|
|
filter_useParsedData : false
|
|
}
|
|
});
|
|
});</pre>
|
|
<ul>
|
|
<li>To only use parsed data in specific columns, set this option to <code>false</code> and use any of the following (they all do the same thing), set in order of priority:
|
|
<ul>
|
|
<li>jQuery data <code>data-filter="parsed"</code>.</li>
|
|
<li>metadata <code>class="{ filter: 'parsed'}"</code>. This requires the metadata plugin.</li>
|
|
<li>headers option <code>headers : { 0 : { filter : 'parsed' } }</code>.</li>
|
|
<li>header class name <code>class="filter-parsed"</code>.</li>
|
|
</ul>
|
|
</li>
|
|
<li>Remember that parsed data most likely doesn't match the actual table cell text, <code>20%</code> becomes <code>20</code> and <code>Jan 1, 2013 12:01 AM</code> becomes <code>1357020060000</code>.</li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="widget-sticky-headers">
|
|
<td><a href="#" class="toggle2">stickyHeaders</a></td>
|
|
<td>String</td>
|
|
<td>"tablesorter-stickyHeader"</td>
|
|
<td>
|
|
Sticky Headers widget: This is the class name applied to the sticky header row (tr). If you change it from the default class name of <code>"tablesorter-stickyHeader"</code> make sure you also update the css! (v2.1).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-sticky-headers"><code>"stickyHeaders"</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["stickyHeaders"],
|
|
widgetOptions : {
|
|
// css class name applied to the sticky header
|
|
stickyHeaders : "tablesorter-stickyHeader"
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-sticky-header.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-resizable">
|
|
<td><a href="#" class="toggle2">resizable</a></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>
|
|
Resizable widget: If this option is set to <code>false</code>, resized column widths will not be saved. Previous saved values will be restored on page reload (v2.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-resizable"><code>"resizable"</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["resizable"],
|
|
widgetOptions : {
|
|
// css class name applied to the sticky header
|
|
resizable : false
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-resizable.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-savesort">
|
|
<td><a href="#" class="toggle2">saveSort</a></td>
|
|
<td>Boolean</td>
|
|
<td>true</td>
|
|
<td>
|
|
saveSort widget: If this option is set to <code>false</code>, new sorts will not be saved. Any previous saved sort will be restored on page reload (v2.4).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-savesort"><code>"saveSort"</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["saveSort"],
|
|
widgetOptions : {
|
|
// if false, the sort will not be saved for next page reload
|
|
saveSort : false
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-savesort.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-uitheme">
|
|
<td><a href="#" class="toggle2">uitheme</a></td>
|
|
<td>String</td>
|
|
<td>"jui"</td>
|
|
<td>
|
|
Instead of the array of icon class names, this option now contains the name of the theme. Currently jQuery UI ("jui") and Bootstrap ("bootstrap") themes are supported. To modify the class names used, extend from the theme (updated v2.4)
|
|
<div class="collapsible">
|
|
<p></p>
|
|
<pre class="prettyprint lang-javascript">// 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
|
|
header : 'ui-widget-header ui-corner-all ui-state-default', // header classes
|
|
footerRow : '',
|
|
footerCells: '',
|
|
icons : 'ui-icon', // icon class added to the <i> in the header
|
|
sortNone : 'ui-icon-carat-2-n-s',
|
|
sortAsc : 'ui-icon-carat-1-n',
|
|
sortDesc : 'ui-icon-carat-1-s',
|
|
active : 'ui-state-active', // applied when column is sorted
|
|
hover : 'ui-state-hover', // hover class
|
|
filterRow : '',
|
|
even : 'ui-widget-content', // even row zebra striping
|
|
odd : 'ui-state-default' // odd row zebra striping
|
|
});</pre>
|
|
|
|
This widget option replaces the previous <a href="#widgetuitheme">widgetUitheme</a>. All theme css names are now contained within the <code>$.tablesorter.themes</code> variable. Extend the default theme as seen above.<br>
|
|
<br>
|
|
|
|
The class names from the <code>$.tablesorter.themes.{name}</code> variable are applied to the table as indicated.<br>
|
|
<br>
|
|
|
|
As before the jQuery UI theme applies the default class names of <code>"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code>"ui-icon-arrowthick-1-s"</code> for the descending sort and <code>"ui-icon-arrowthick-1-n"</code> 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: <a class="external" href="http://jqueryui.com/themeroller/">http://jqueryui.com/themeroller/</a><br>
|
|
<br>
|
|
Use the <a href="#widget-uitheme"><code>"uitheme"</code></a> option to change the css class name as follows:
|
|
<pre class="prettyprint lang-javascript">$(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
|
|
}
|
|
});
|
|
});</pre>
|
|
|
|
To add a new theme, define it as follows; replace "custom" with the name of your theme:
|
|
<pre class="prettyprint lang-javascript">$.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
|
|
}</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-ui-theme.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="widget-zebra">
|
|
<td><a href="#" class="toggle2">zebra</a></td>
|
|
<td>Array</td>
|
|
<td>[ "even", "odd" ]</td>
|
|
<td>
|
|
zebra widget: When the zebra striping widget is initialized, it automatically applied the default class names of <code>"even"</code> and <code>"odd"</code>. (Modified v2.1).
|
|
<div class="collapsible">
|
|
<br>
|
|
Use the <a href="#widget-zebra"><code>"zebra"</code></a> option to change the theme as follows:
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$("table").tablesorter({
|
|
widgets: ["zebra"], // initialize zebra striping of the table
|
|
widgetOptions: {
|
|
zebra: [ "normal-row", "alt-row" ]
|
|
}
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-widget-zebra.html">Example</a></td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<a id="methods"></a>
|
|
<h1>Methods</h1>
|
|
|
|
<div class="tip">
|
|
<p></p>
|
|
tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
|
|
<br>
|
|
<em>TIP!</em> Click on the link in the method column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
|
|
</div>
|
|
|
|
<table id="method" class="tablesorter">
|
|
<thead>
|
|
<tr>
|
|
<th>Method</th>
|
|
<th>Description</th>
|
|
<th>Link</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<tr id="addrows">
|
|
<td><a href="#" class="toggle2">addRows</a></td>
|
|
<td>Use this method to add table rows. (v2.0.16).
|
|
<div class="collapsible">
|
|
It does not work the same as "update" in that it only adds rows, it does not remove them.<br>
|
|
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.
|
|
<pre class="prettyprint lang-javascript">// 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 the current sort; set to false to prevent resort, otherwise
|
|
// any other value in resort will automatically trigger the table resort.
|
|
// A callback method was added in 2.3.9.
|
|
resort = true,
|
|
callback = function(table){
|
|
alert('rows have been added!');
|
|
};
|
|
$('table')
|
|
.find('tbody').append($row)
|
|
.trigger('addRows', [$row, resort, callback]);</pre></div>
|
|
</td>
|
|
<td><a href="example-add-rows.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sorton">
|
|
<td><a href="#" class="toggle2">sorton</a></td>
|
|
<td>Use this method to sort an initialized table in the desired order.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">// 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)
|
|
// A callback method was added in 2.3.9.
|
|
$("table").trigger("sorton", [sort, callback]);</pre></div>
|
|
</td>
|
|
<td><a href="example-trigger-sort.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortreset-method">
|
|
<td><a href="#" class="toggle2">sortReset</a></td>
|
|
<td>Use this method to reset the table to it's initial unsorted state. <span class="tip"><em>New</em></span> v2.4.7.
|
|
<div class="collapsible">
|
|
Don't confuse this method with the <a href="#sortreset"><code>sortReset</code> option</a>. This method immediately resets the entire table sort, while the option only resets the column sort after a third click.
|
|
<pre class="prettyprint lang-javascript">// Reset the table (make it unsorted)
|
|
$("table").trigger("sortReset");</pre></div>
|
|
</td>
|
|
<td><a href="example-method-sortreset.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="update">
|
|
<td><a href="#" class="toggle2">update</a></td>
|
|
<td>Update the stored tablesorter data and the table.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">// Add new content
|
|
$("table tbody").append(html);
|
|
|
|
// let the plugin know that we made a update
|
|
// the resort flag set to anything BUT false (no quotes) will trigger an automatic
|
|
// table resort using the current sort
|
|
// 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.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
|
|
|
|
// set sorting column and direction, this will sort on the first and third column
|
|
var sorting = [[2,1],[0,0]];
|
|
$("table").trigger("sorton", [sorting]);</pre></div>
|
|
</td>
|
|
<td><a href="example-ajax.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="appendcache">
|
|
<td><a href="#" class="toggle2">appendCache</a></td>
|
|
<td>Update a table that has had its data dynamically changed; used in conjunction with "update".<br>
|
|
<div class="collapsible">
|
|
Use this method when more than just one cell like in the "updateCell" method, but you may possibly have to trigger two events: both "update" and "appendCache".<br>
|
|
<br>
|
|
Note: This is the only method the pager widget uses - the entire table is stored in the cache, but only the visible portion is actually exists in the table.
|
|
<pre class="prettyprint lang-javascript">// Table data was just dynamically changed (more than one cell)
|
|
$("table")
|
|
.trigger("update")
|
|
.trigger("appendCache");</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="updatecell">
|
|
<td><a href="#" class="toggle2">updateCell</a></td>
|
|
<td>Update a table cell in the tablesorter data.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function() {
|
|
$("table").tablesorter();
|
|
|
|
$("td.discount").click(function(){
|
|
|
|
// randomize a number
|
|
var resort = false,
|
|
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)
|
|
// leave the resort flag as undefined, or with any other value, to automatically resort the table
|
|
// $("table").trigger("updateCell", [this]); < - resort is undefined so the table WILL resort
|
|
$("table").trigger("updateCell", [this, resort]);
|
|
|
|
// 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
|
|
|
|
// set sorting column and direction, this will sort on the first and third column
|
|
var sorting = [[3,1]];
|
|
$("table").trigger("sorton", [sorting]);
|
|
|
|
return false;
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-update-cell.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="applywidgetid">
|
|
<td><a href="#" class="toggle2">applyWidgetId</a></td>
|
|
<td>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.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
// initialize tablesorter without the widget
|
|
$("table").tablesorter();
|
|
|
|
// click a button to apply the zebra striping
|
|
$("button").click(function(){
|
|
$('table').trigger('applyWidgetId', ['zebra']);
|
|
});
|
|
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-apply-widget.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="applywidgets">
|
|
<td><a href="#" class="toggle2">applyWidgets</a></td>
|
|
<td>Apply the set widgets to the table. This method can be used after a table has been initialized, but it won't work unless you update the configuration settings. See the example, it's easier than describing it.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">// Update the list of widgets to apply to the table (add or remove)
|
|
// $("table").data("tablesorter").widgets = ["zebra"]; // works the same as
|
|
$("table")[0].config.widgets = ["zebra"];
|
|
|
|
// This method applies the widget - no need to keep updating
|
|
$('table').trigger('applyWidgets');
|
|
</pre></div>
|
|
</td>
|
|
<td><a href="example-apply-widget.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="destroy">
|
|
<td><a href="#" class="toggle2">destroy</a></td>
|
|
<td>Use this method to remove tablesorter from the table.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">// Remove tablesorter and all classes
|
|
$("table").trigger("destroy");
|
|
|
|
// Remove tablesorter and all classes but the "tablesorter" class on the table
|
|
$("table").trigger("destroy", [false];</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="refreshwidgets">
|
|
<td><a href="#" class="toggle2">refreshWidgets</a></td>
|
|
<td>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. <span class="tip"><em>New</em></span> v2.4.
|
|
<div class="collapsible"><br>
|
|
Trigger this method using either of the following methods (they are equivalent):
|
|
<pre class="prettyprint lang-javascript">// trigger a refresh widget event
|
|
$('table').trigger('refreshWidgets', [doAll, dontapply]);
|
|
|
|
// Use the API directly
|
|
$.tablesorter.refreshWidgets(table, doAll, dontapply)</pre>
|
|
<ul>
|
|
<li>If <code>doAll</code> is <code>true</code> it removes all widgets from the table. If <code>false</code> only non-current widgets (from the <code>widgets</code> option) are removed.</li>
|
|
<li>When done removing widgets, the widget re-initializes the currently selected widgets, unless the <code>dontapply</code> parameter is <code>true</code> leaving the table widget-less.</li>
|
|
<li>Note that if the <code>widgets</code> 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 <code>$('table')[0].config.widgets = [];</code></li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<td><a href="example-apply-widget.html">Example</a></td>
|
|
</tr>
|
|
</tbody>
|
|
|
|
<!-- non-sorting tbody -->
|
|
<tbody id="methods-widgets" class="tablesorter-infoOnly">
|
|
<tr><th colspan="5">Widget Methods</th></tr>
|
|
</tbody>
|
|
|
|
<tbody>
|
|
<tr id="search">
|
|
<td><a href="#" class="toggle2">search</a></td>
|
|
<td>Trigger the filter widget to update the search from current inputs and/or selections. <span class="tip"><em>Updated!</em></span> v2.4.
|
|
<div class="collapsible">
|
|
This first method sends an array with the search strings to the filter widget.<pre class="prettyprint lang-javascript">$(function(){
|
|
// apply "2?%" filter to the fifth column (zero-based index)
|
|
var columns = [];
|
|
columns[4] = '2?%'; // or define the array this way [ '', '', '', '', '2?%' ]
|
|
$('table').trigger('search', [columns]);
|
|
});</pre>
|
|
or, directly add the search string to the filter input as follows:<pre class="prettyprint lang-javascript">$(function(){
|
|
// apply "2?%" filter to the fifth column (zero-based index)
|
|
$('table').find('input.tablesorter-filter').eq(4).val('2?%');
|
|
$('table').trigger('search', false); // add a false flag to skip the search delay
|
|
});</pre></div>
|
|
</td>
|
|
<td>Ex: <a href="example-widget-filter.html">1</a> <a href="example-widget-filter-custom.html">2</a> <a href="example-option-show-processing.html">3</a></td>
|
|
</tr>
|
|
</tbody>
|
|
|
|
<!-- non-sorting tbody -->
|
|
<tbody id="methods-pager" class="tablesorter-infoOnly">
|
|
<tr><th colspan="5">Pager Methods</th></tr>
|
|
</tbody>
|
|
|
|
<tbody>
|
|
<tr id="pagesize">
|
|
<td><a href="#" class="toggle2">pageSize</a></td>
|
|
<td>Trigger the pager to change the page size. <span class="tip"><em>New!</em></span> v2.7.4.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$('table').trigger('pageSize', 15);
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr id="pageset">
|
|
<td><a href="#" class="toggle2">pageSet</a></td>
|
|
<td>Trigger the pager to change the current page. <span class="tip"><em>New!</em></span> v2.7.7.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
$('table').trigger('pageSet', 3);
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<a id="events"></a>
|
|
<h1>Events</h1>
|
|
|
|
<div class="tip">
|
|
<p></p>
|
|
tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
|
|
<br>
|
|
<em>TIP!</em> Click on the link in the event column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
|
|
</div>
|
|
|
|
<table id="event" class="tablesorter">
|
|
<thead>
|
|
<tr>
|
|
<th>Event</th>
|
|
<th>Description</th>
|
|
<th>Link</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
|
|
<tr id="initialized">
|
|
<td><a href="#" class="toggle2">initialized</a></td>
|
|
<td>This event fires when tablesorter has completed initialization. (v2.2).
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(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
|
|
}
|
|
});
|
|
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="sortbegin">
|
|
<td><a href="#" class="toggle2">sortBegin</a></td>
|
|
<td>This event fires immediately before tablesorter begins resorting the table.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
|
|
// initialize the tablesorter plugin
|
|
$("table").tablesorter();
|
|
|
|
// bind to sort events
|
|
$("table").bind("sortBegin",function(e, table) {
|
|
// do something crazy!
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="sortstart">
|
|
<td><a href="#" class="toggle2">sortStart</a></td>
|
|
<td>This event fires immediately after the tablesorter header has been clicked, initializing a resort.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(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();
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-triggers.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="sortend">
|
|
<td><a href="#" class="toggle2">sortEnd</a></td>
|
|
<td>This event fires when tablesorter has completed resorting the table.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(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();
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-triggers.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="updatecomplete">
|
|
<td><a href="#" class="toggle2">updateComplete</a></td>
|
|
<td>This event fires after tablesorter has completed updating. (v.2.3.9)
|
|
<div class="collapsible">
|
|
This occurs after an "update", "updateCell" or "addRows" method was called, but before any callback functions are executed.
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
|
|
// initialize the tablesorter plugin
|
|
$("table").tablesorter();
|
|
|
|
// bind to sort events
|
|
$("table")
|
|
.bind("updateComplete",function(e, table) {
|
|
// do something after the table has been altered;
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
<!-- non-sorting tbody -->
|
|
<tbody id="events-pager" class="tablesorter-infoOnly">
|
|
<tr><th colspan="5">Pager Events</th></tr>
|
|
</tbody>
|
|
|
|
<!-- Pager addon events -->
|
|
<tbody>
|
|
<tr id="pagerchange">
|
|
<td><a href="#" class="toggle2">pagerChange</a></td>
|
|
<td>This event fires when the pager plugin begins to render the table on the currently selected page. (v2.0.7).
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
|
|
// initialize the sorter
|
|
$("table")
|
|
.tablesorter()
|
|
|
|
// initialize the pager plugin
|
|
.tablesorterPager({
|
|
container: $("#pager")
|
|
})
|
|
|
|
// bind to pager events
|
|
.bind('pagerChange pagerComplete', function(e,c){
|
|
// c.totalPages contains the total number of pages
|
|
$('#display').html( e.type + " event triggered, now on page " + (c.page + 1) );
|
|
});
|
|
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-pager.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="pagercomplete">
|
|
<td><a href="#" class="toggle2">pagerComplete</a></td>
|
|
<td>This event fires when the pager plugin has completed its render of the table on the currently selected page. (v2.0.7).
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
|
|
// initialize the sorter
|
|
$("table")
|
|
.tablesorter()
|
|
|
|
// initialize the pager plugin
|
|
.tablesorterPager({
|
|
container: $("#pager")
|
|
})
|
|
|
|
// bind to pager events
|
|
.bind('pagerChange pagerComplete', function(e,c){
|
|
// c.totalPages contains the total number of pages
|
|
$('#display').html( e.type + " event triggered, now on page " + (c.page + 1) );
|
|
});
|
|
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-pager.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="pagerbeforeinitialized">
|
|
<td><a href="#" class="toggle2">pagerBeforeInitialized</a></td>
|
|
<td>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. <span class="tip"><em>New</em></span> v2.4.4.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
|
|
$("table")
|
|
|
|
// initialize the sorter
|
|
.tablesorter()
|
|
|
|
// bind to pager initialized event BEFORE calling the addon
|
|
.bind('pagerBeforeInitialized', function(e, c){
|
|
// e = event object; c = pager options
|
|
})
|
|
|
|
// initialize the pager plugin
|
|
.tablesorterPager({
|
|
container: $("#pager")
|
|
});
|
|
|
|
});</pre></div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
|
|
<tr id="pagerinitialized">
|
|
<td><a href="#" class="toggle2">pagerInitialized</a></td>
|
|
<td>This event fires when the pager plugin has completed initialization. <span class="tip"><em>New</em></span> v2.4.4.
|
|
<div class="collapsible">
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
|
|
$("table")
|
|
|
|
// initialize the sorter
|
|
.tablesorter()
|
|
|
|
// bind to pager initialized event BEFORE calling the addon
|
|
.bind('pagerInitialized', function(e, c){
|
|
// c.totalPages contains the total number of pages
|
|
$('#display').html( e.type + " event triggered, now on page " + (c.page + 1) );
|
|
})
|
|
|
|
// initialize the pager plugin
|
|
.tablesorterPager({
|
|
container: $("#pager")
|
|
});
|
|
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-pager.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="pagemoved">
|
|
<td><a href="#" class="toggle2">pageMoved</a></td>
|
|
<td>This event fires when the pager plugin begins to change to the selected page. <span class="tip"><em>New</em></span> v2.4.4.
|
|
<div class="collapsible">
|
|
This event may fire before the <code>pagerComplete</code> event when ajax processing is involved, or after the <code>pagerComplete</code> on normal use.
|
|
See <a href="https://github.com/Mottie/tablesorter/pull/153">issue #153</a>.
|
|
<pre class="prettyprint lang-javascript">$(function(){
|
|
|
|
// initialize the sorter
|
|
$("table")
|
|
.tablesorter()
|
|
|
|
// initialize the pager plugin
|
|
.tablesorterPager({
|
|
container: $("#pager")
|
|
})
|
|
|
|
// bind to pager events
|
|
.bind('pageMoved', function(e, c){
|
|
// c.totalPages contains the total number of pages
|
|
$('#display').html( e.type + " event triggered, now on page " + (c.page + 1) );
|
|
});
|
|
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-pager.html">Example</a></td>
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
<!-- non-sorting tbody -->
|
|
<tbody id="events-widgets" class="tablesorter-infoOnly">
|
|
<tr><th colspan="5">Widget Events</th></tr>
|
|
</tbody>
|
|
|
|
<!-- widget events -->
|
|
<tbody>
|
|
|
|
<tr id="filterinit">
|
|
<td><a href="#" class="toggle2">filterInit</a></td>
|
|
<td>Event triggered when the filter widget has finished initializing. <span class="tip"><em>New</em></span> v2.4.
|
|
<div class="collapsible">
|
|
You can use this event to modify the filter elements (row, inputs and/or selects) as desired. Use it as follows:<pre class="prettyprint lang-javascript">$(function(){
|
|
$('table').bind('filterInit', function(){
|
|
$(this).find('tr.tablesorter-filter-row').addClass('fred');
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-option-show-processing.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="filterstart">
|
|
<td><a href="#" class="toggle2">filterStart</a></td>
|
|
<td>Event triggered when the filter widget has started processing the search. <span class="tip"><em>New</em></span> v2.4.
|
|
<div class="collapsible">
|
|
You can use this event to do something like add a class to the filter row. Use it as follows:<pre class="prettyprint lang-javascript">$(function(){
|
|
$('table').bind('filterStart', function(){
|
|
$(this).find('tr.tablesorter-filter-row').addClass('filtering');
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-option-show-processing.html">Example</a></td>
|
|
</tr>
|
|
|
|
<tr id="filterend">
|
|
<td><a href="#" class="toggle2">filterEnd</a></td>
|
|
<td>Event triggered when the filter widget has finished processing the search. <span class="tip"><em>New</em></span> v2.4.
|
|
<div class="collapsible">
|
|
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:<pre class="prettyprint lang-javascript">$(function(){
|
|
$('table').bind('filterEnd', function(){
|
|
$(this).find('tr.tablesorter-filter-row').removeClass('filtering');
|
|
});
|
|
});</pre></div>
|
|
</td>
|
|
<td><a href="example-option-show-processing.html">Example</a></td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<a id="Download"></a>
|
|
<h1>Download</h1>
|
|
|
|
<p><strong>Full release</strong> - Plugin, Documentation, Add-ons, Themes. Download: <a class="download zip" href="https://github.com/Mottie/tablesorter/zipball/master">zip</a> or <a class="download tar" href="https://github.com/Mottie/tablesorter/tarball/master">tar.gz</a></p>
|
|
|
|
<p><strong>Pick n choose</strong> - Place at least the required files in a directory on your webserver that is accessible to a web browser. Record this location.</p>
|
|
|
|
<strong id="Download-Required">Required:</strong>
|
|
<ul>
|
|
<li><a class="external" href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery">jQuery</a> (1.2.6 or higher; some demos & <a href="http://api.jquery.com/data/#data-html5">HTML5 data-attributes</a> need jQuery 1.4.3+)</li>
|
|
<li><a href="../js/jquery.tablesorter.min.js">jquery.tablesorter.min.js</a> (19kb, minified for production - please put the file on your server)</li>
|
|
</ul>
|
|
|
|
<strong id="Download-Addons">Optional / Add-Ons:</strong>
|
|
<ul>
|
|
<li><a class="external" href="http://plugins.jquery.com/files/jquery.metadata.2.1.zip">jQuery Metadata 2.1</a> (4kb, required for setting <a href="#metadata">inline options</a>)</li>
|
|
<li><a href="../js/jquery.tablesorter.js">jquery.tablesorter.js</a> (47kb/<a href="../js/jquery.tablesorter.min.js">23kb min</a>)</li>
|
|
<li><a href="../addons/pager/jquery.tablesorter.pager.js">jquery.tablesorter.pager.js</a> (16kb/<a href="../addons/pager/jquery.tablesorter.pager.min.js">8kb min</a>, <a href="example-pager.html">demo</a>)</li>
|
|
<li><a href="../js/jquery.tablesorter.widgets.js">jquery.tablesorter.widgets.js</a> (36kb/<a href="../js/jquery.tablesorter.widgets.min.js">17kb min</a>, includes the jQuery UI theme, columns styling, resizable columns, filter, sticky header and save sort widgets.</li>
|
|
</ul>
|
|
|
|
<strong id="Download-Themes">Themes:</strong>
|
|
<p>Theme zip files have been removed. There are now numerous themes available which <a href="themes.html">can be seen here</a></p>
|
|
|
|
<a id="Compatibility"></a>
|
|
<h1>Browser Compatibility</h1>
|
|
|
|
<p>tablesorter has been tested successfully in the following browsers with Javascript enabled:</p>
|
|
<ul>
|
|
<li>Firefox 2+</li>
|
|
<li>Internet Explorer 6+</li>
|
|
<li>Safari 2+</li>
|
|
<li>Opera 9+</li>
|
|
<li>Konqueror</li>
|
|
</ul>
|
|
|
|
<p><a class="external" href="http://docs.jquery.com/Browser_Compatibility">jQuery Browser Compatibility</a></p>
|
|
|
|
<a id="Support"></a>
|
|
<h1>Support</h1>
|
|
|
|
<p>If you are having a problem with the plugin or you want to submit a feature request, please <a href="https://github.com/Mottie/tablesorter/issues">submit an issue</a>.</p>
|
|
|
|
<p>If you would like to contribute, <a href="https://github.com/Mottie/tablesorter">fork a copy on github</a>.</p>
|
|
|
|
<p>Some basic <a href="../test.html">unit testing</a> has been added. If you would like to add more or report a problem, please use the appropriate link above. <span class="tip"><em>New!</em></span> v2.6.</p>
|
|
|
|
<p>Support is also available through the <a class="external" href="http://jquery.com/discuss/">jQuery Mailing List</a> or <a class="external" href="http://stackoverflow.com/questions/tagged/tablesorter">StackOverflow</a>.</p>
|
|
|
|
<p>Access to the jQuery Mailing List is also available through <a class="external" href="http://www.nabble.com/JQuery-f15494.html">Nabble Forums</a>.</p>
|
|
|
|
<a id="Credits"></a>
|
|
<h1>Credits</h1>
|
|
<p>Written by Christian Bach.</p>
|
|
<p>
|
|
Documentation written by <a class="external" href="http://www.ghidinelli.com">Brian Ghidinelli</a>,
|
|
based on <a class="external" href="http://malsup.com/jquery/">Mike Alsup's</a> great documention.<br>
|
|
Additional & Missing documentation, alphanumeric sort, numerous widgets, unit testing and other changes added by <a class="external" href="https://github.com/Mottie/tablesorter">Mottie</a>.
|
|
</p>
|
|
<p>
|
|
<a class="external" href="http://ejohn.org">John Resig</a> for the fantastic <a class="external" href="http://jquery.com">jQuery</a>
|
|
</p>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|