tablesorter/docs/index.html

1705 lines
74 KiB
HTML
Raw Normal View History

2011-07-17 15:01:18 +00:00
<!DOCTYPE html>
<html>
2011-06-22 23:19:27 +00:00
<head>
2011-07-17 15:01:18 +00:00
<meta charset="utf-8">
<title>jQuery plugin: Tablesorter 2.0</title>
2011-06-22 23:19:27 +00:00
2011-07-17 15:01:18 +00:00
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
2011-06-22 23:19:27 +00:00
2011-07-17 15:01:18 +00:00
<!-- Demo stuff -->
<link rel="stylesheet" href="css/jq.css">
<script src="js/chili/jquery.chili-2.2.js"></script>
<script src="js/chili/recipes.js"></script>
<script src="js/docs.js"></script>
2011-06-22 23:19:27 +00:00
2011-07-17 15:01:18 +00:00
<!-- Tablesorter: required -->
<link href="../css/blue/style.css" rel="stylesheet">
<script src="../js/jquery.tablesorter.js"></script>
<script src="../js/jquery.tablesorter.widgets.js"></script>
2011-07-17 15:01:18 +00:00
<script>
2011-06-22 23:19:27 +00:00
$(function() {
2011-07-17 15:01:18 +00:00
$("#tablesorter-demo").tablesorter({sortList:[[0,0],[2,1]],widgets:['zebra']});
2012-05-04 05:59:43 +00:00
$("table.options").tablesorter({sortList:[[0,0]],headers:{3:{sorter:false},4:{sorter:false}},widgets:['stickyHeaders']});
$("#methods,#events").tablesorter({sortList:[[0,0]],headers:{1:{sorter:false},2:{sorter:false}}});
2011-06-22 23:19:27 +00:00
});
2011-07-17 15:01:18 +00:00
</script>
2011-06-22 23:19:27 +00:00
</head>
2011-07-17 15:01:18 +00:00
<body id="root">
<div id="banner">
2011-06-22 23:19:27 +00:00
<h1>table<em>sorter</em></h1>
<h2>Documentation</h2>
<h3>Flexible client-side table sorting</h3>
<a href="#"></a>
</div>
<div id="main">
<div class="digg">
</div>
<p>
2012-03-03 01:38:02 +00:00
<strong>Author:</strong> Christian Bach<br>
2012-04-12 22:05:28 +00:00
<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>
2011-07-17 15:01:18 +00:00
<strong>Licence:</strong>
2011-06-22 23:19:27 +00:00
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>
2011-07-17 15:01:18 +00:00
2011-06-22 23:19:27 +00:00
<p class="tip update">
2012-03-07 18:06:35 +00:00
<em>Note!</em> Version 2.0.3 of the tablesorter docs are available in russian, head over to <a class="external" href="http://tablesorter.ru/docs/">tablesorter.ru</a>
2011-06-22 23:19:27 +00:00
</p>
2011-07-17 15:01:18 +00:00
2011-06-22 23:19:27 +00:00
<p class="tip">
<em>Helping out!</em> If you like tablesorter and you're feeling generous, take a look at my <a class="external" href="http://www.amazon.com/gp/registry/wishlist/3VAOWCL63NEA6/ref=wl_web/">Amazon Wish List</a> or make a donation.
</p>
2011-07-17 15:01:18 +00:00
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="christian.bach@polyester.se">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Tablesorter donation">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
2012-03-07 18:06:35 +00:00
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
2011-07-17 15:01:18 +00:00
</form>
2011-06-22 23:19:27 +00:00
<p>Comments and love letters can be sent to: <span class="email">christian at tablesorter dot com</span>.</p>
2011-07-17 15:01:18 +00:00
2011-06-22 23:19:27 +00:00
<p> </p>
2012-03-07 18:06:35 +00:00
<a id="Contents"></a>
2011-06-22 23:19:27 +00:00
<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>
2012-03-07 18:06:35 +00:00
<li><a href="#Widget-options">Widget Options</a> <span class="tip"><em>New!</em></span> v2.1</li>
2012-02-01 05:14:28 +00:00
<li><a href="#Methods">Methods</a></li>
<li><a href="#Events">Events</a></li>
2011-06-22 23:19:27 +00:00
<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>
2012-03-07 18:06:35 +00:00
<a id="Introduction"></a>
2011-06-22 23:19:27 +00:00
<h1>Introduction</h1>
<p>
tablesorter is a <a class="external" href="http://jquery.com">jQuery</a> plugin for turning a
2011-07-17 15:01:18 +00:00
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.
2011-06-22 23:19:27 +00:00
It has many useful features including:
</p>
2011-07-17 15:01:18 +00:00
<ul>
<li>Multi-column sorting</li>
<li>Multi-tbody sorting - see the <a href="#options">options</a> table below</li>
2011-07-17 15:01:18 +00:00
<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>
<!--
2011-06-22 23:19:27 +00:00
<li>Support for ROWSPAN and COLSPAN on TH elements</li>
-->
2011-07-17 15:01:18 +00:00
<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>
2011-06-22 23:19:27 +00:00
<li>Small code size</li>
2011-07-17 15:01:18 +00:00
</ul>
2012-03-07 18:06:35 +00:00
<a id="Demo"></a>
2011-06-22 23:19:27 +00:00
<h1>Demo</h1>
2012-03-07 18:06:35 +00:00
<table id="tablesorter-demo" class="tablesorter">
2011-06-22 23:19:27 +00:00
<thead>
<tr>
2011-07-17 15:01:18 +00:00
<th>Account #</th>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
<td>A42b</td>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
<td>A255</td>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
<td>A33</td>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
<td>A1</td>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
<td>A102</td>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
<td>A42a</td>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
2011-06-22 23:19:27 +00:00
<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!
2011-07-17 15:01:18 +00:00
</p>
2012-03-07 18:06:35 +00:00
<a id="Getting-Started"></a>
2011-06-22 23:19:27 +00:00
<h1>Getting started</h1>
<p>
To use the tablesorter plugin, include the <a class="external" href="http://jquery.com">jQuery</a>
2011-07-17 15:01:18 +00:00
library and the tablesorter plugin inside the <code class="hilight">&lt;head&gt;</code> tag
2011-06-22 23:19:27 +00:00
of your HTML document:
</p>
2011-07-17 15:01:18 +00:00
<pre class="html">&lt;script type=&quot;text/javascript&quot; src=&quot;/path/to/jquery-latest.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/path/to/jquery.tablesorter.js&quot;&gt;&lt;/script&gt;</pre>
2011-06-22 23:19:27 +00:00
<p>tablesorter works on standard HTML tables. You must include THEAD and TBODY tags:</p>
2011-07-17 15:01:18 +00:00
<pre class="html">&lt;table id="myTable" class="tablesorter"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Last Name&lt;/th&gt;
&lt;th&gt;First Name&lt;/th&gt;
&lt;th&gt;Email&lt;/th&gt;
&lt;th&gt;Due&lt;/th&gt;
&lt;th&gt;Web Site&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Smith&lt;/td&gt;
&lt;td&gt;John&lt;/td&gt;
&lt;td&gt;jsmith@gmail.com&lt;/td&gt;
&lt;td&gt;$50.00&lt;/td&gt;
&lt;td&gt;http://www.jsmith.com&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bach&lt;/td&gt;
&lt;td&gt;Frank&lt;/td&gt;
&lt;td&gt;fbach@yahoo.com&lt;/td&gt;
&lt;td&gt;$50.00&lt;/td&gt;
&lt;td&gt;http://www.frank.com&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Doe&lt;/td&gt;
&lt;td&gt;Jason&lt;/td&gt;
&lt;td&gt;jdoe@hotmail.com&lt;/td&gt;
&lt;td&gt;$100.00&lt;/td&gt;
&lt;td&gt;http://www.jdoe.com&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conway&lt;/td&gt;
&lt;td&gt;Tim&lt;/td&gt;
&lt;td&gt;tconway@earthlink.net&lt;/td&gt;
&lt;td&gt;$50.00&lt;/td&gt;
&lt;td&gt;http://www.timconway.com&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
2011-06-22 23:19:27 +00:00
&lt;/table&gt;</pre>
<p>Start by telling tablesorter to sort your table when the document is loaded:</p>
2011-07-17 15:01:18 +00:00
<pre class="js">$(function(){
$("#myTable").tablesorter();
2011-06-22 23:19:27 +00:00
});</pre>
<p>
2011-07-17 15:01:18 +00:00
Click on the headers and you'll see that your table is now sortable! You can
2011-06-22 23:19:27 +00:00
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>
2011-07-17 15:01:18 +00:00
<pre class="js">$(function(){
2012-03-07 18:06:35 +00:00
$("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
2011-06-22 23:19:27 +00:00
});</pre>
2011-07-17 15:01:18 +00:00
2011-06-22 23:19:27 +00:00
<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>
2012-03-07 18:06:35 +00:00
<a id="Examples"></a>
2011-07-17 15:01:18 +00:00
<h1>Examples</h1>
<p>
These examples will show what's possible with tablesorter. You need Javascript enabled to
2011-06-22 23:19:27 +00:00
run these samples, just like you and your users will need Javascript enabled to use tablesorter.
</p>
2011-07-17 15:01:18 +00:00
2011-10-14 01:57:46 +00:00
<div class="box">
<h3>Basic</h3>
<h4>Sorting</h4>
2011-06-22 23:19:27 +00:00
<ul>
2011-07-17 15:01:18 +00:00
<li><a href="example-option-sort-list.html">Set an initial sorting order using options</a></li>
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
<li><a href="example-option-sort-append.html">Append a sort to the selected sorting order</a></li>
2011-11-08 03:47:46 +00:00
<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>
2011-06-22 23:19:27 +00:00
<li><a href="example-option-sort-order.html">Direction of initial sort</a></li>
<li><a href="example-options-headers.html">Disable sort using headers options</a></li>
<li><a href="example-options-headers-locked.html">Lock sort order using header options</a></li>
<li><a href="example-options-headers-order.html">Set initial sort order using header options</a></li>
<li><a href="example-option-sortreset-sortrestart.html">Using sortReset &amp; sortRestart options</a></li>
2012-04-12 22:05:28 +00:00
<li><a href="example-option-sort-empty.html">Sorting empty cells</a> <span class="tip"><em>New!</em></span> v2.1.11</li>
2011-07-17 15:01:18 +00:00
<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> <span class="tip"><em>New!</em></span> v2.2</li>
<li><a href="example-locale-sort.html">Sorting Accented Characters</a> <span class="tip"><em>New!</em></span> v2.2</li>
2012-05-05 01:42:04 +00:00
<li><a href="example-multiple-tbodies.html">Sorting with Multiple Tbodies</a> <span class="tip"><em>New!</em></span> v2.2</li>
2011-06-22 23:19:27 +00:00
</ul>
2011-10-14 01:57:46 +00:00
<h4>Parsers / Extracting Content</h4>
2011-06-22 23:19:27 +00:00
<ul>
2011-10-14 01:57:46 +00:00
<li><a href="example-option-digits.html">Dealing with digits!</a></li>
2012-02-01 05:14:28 +00:00
<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>
2012-05-07 19:22:24 +00:00
<li><a href="example-parsers-jquery-data.html">Disable or set the column parser using jQuery Data</a> <span class="tip"><em>New!</em></span> v2.3</li>
2012-03-07 18:06:35 +00:00
<li><a href="example-option-date-format.html">Changing the date format</a> (v2.0.23)</li>
2011-10-14 01:57:46 +00:00
<li><a href="example-parsers.html">Parser, writing your own</a></li>
2012-03-07 18:06:35 +00:00
<li><a href="example-parsers-advanced.html">Parser, writing your own, advanced use</a> <span class="tip"><em>New!</em></span> v2.1</li>
2011-10-14 01:57:46 +00:00
<li><a href="example-option-text-extraction.html">Dealing with markup inside cells (textExtraction function)</a></li>
2011-07-17 15:01:18 +00:00
</ul>
2011-10-14 01:57:46 +00:00
2012-03-07 18:06:35 +00:00
<h4>Widgets / Plugins</h4>
2011-10-14 01:57:46 +00:00
<ul>
<li><a href="example-apply-widget.html">Applying widgets</a></li>
2012-02-01 05:14:28 +00:00
<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-ui-theme.html">jQuery UI theme widget</a> (v2.0.9)</li>
2012-03-07 18:06:35 +00:00
<li><a href="example-widget-resizable.html">Resizable Columns widget</a> (v2.0.23.1)</li>
<li><a href="example-widget-savesort.html">Save sort widget</a> (v2.0.27)</li>
2012-02-01 05:14:28 +00:00
<li><a href="example-widget-sticky-header.html">Sticky header widget</a> (v2.0.21.1)</li>
2011-10-14 01:57:46 +00:00
<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>
2012-03-07 18:06:35 +00:00
<li><a href="example-pager-ajax.html">Pager plugin - ajax</a> <span class="tip"><em>New!</em></span> v2.1</li>
2011-10-14 01:57:46 +00:00
</ul>
</div>
<div class="box">
<h3>Advanced</h3>
<h4>Adding / Removing Content</h4>
2011-06-22 23:19:27 +00:00
<ul>
<li><a href="example-empty-table.html">Initializing tablesorter on a empty table</a></li>
2011-07-17 15:01:18 +00:00
<li><a href="example-ajax.html">Appending table data with ajax</a></li>
2012-02-01 05:14:28 +00:00
<li><a href="example-add-rows.html">Adding a table row</a> (v2.0.16)</li>
2011-06-22 23:19:27 +00:00
<li><a href="example-update-cell.html">Update the table after cell content has changed</a></li>
2011-10-14 01:57:46 +00:00
<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>
2012-02-01 05:14:28 +00:00
<li><a href="example-widget-ui-theme.html">jQuery UI theme widget</a> (v2.0.9)</li>
2011-07-17 15:01:18 +00:00
<li><a href="example-option-render-header.html">Modify how the header is rendered to allow for custom styling</a></li>
2011-10-14 01:57:46 +00:00
</ul>
2011-10-18 15:52:53 +00:00
<br>
2011-10-14 01:57:46 +00:00
<h3>Other</h3>
<h4>Options &amp; Events</h4>
<ul>
<li><a href="example-triggers.html">Triggers sortEnd and sortStart (Displaying sorting progress)</a></li>
2011-06-22 23:19:27 +00:00
<li><a href="example-extending-defaults.html">Extending default options</a></li>
2011-07-17 15:01:18 +00:00
<li><a href="example-option-debug.html">Enabling debug mode</a></li>
2011-06-22 23:19:27 +00:00
</ul>
2011-07-17 15:01:18 +00:00
2012-03-07 18:06:35 +00:00
<h4>Playgrounds & Other demos</h4>
<ul>
<li><a href="http://jsfiddle.net/Mottie/vCTHw/10/">tablesorter basic demo</a> (includes widgets)</li>
<li><a href="http://jsfiddle.net/Mottie/vCTHw/11/">tablesorter basic demo using jQuery UI theme</a></li>
<li><a href="http://jsfiddle.net/Mottie/aEL9t/7/">tablesorter basic demo with pager plugin</a></li>
<li><a href="https://github.com/Mottie/tablesorter/wiki">More demos - added to wiki pages</a></li>
</ul>
2011-10-14 01:57:46 +00:00
<h4>Metadata - setting inline options</h4>
2011-06-22 23:19:27 +00:00
<ul>
2012-05-07 19:22:24 +00:00
<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.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>
2011-10-14 01:57:46 +00:00
<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>
2011-06-22 23:19:27 +00:00
</ul>
2011-10-14 01:57:46 +00:00
</div>
<br class="clear">
2011-06-22 23:19:27 +00:00
2012-03-07 18:06:35 +00:00
<a id="Configuration"></a>
2011-06-22 23:19:27 +00:00
<h1>Configuration</h1>
2011-07-17 15:01:18 +00:00
<p class="tip">
2012-03-07 18:06:35 +00:00
tablesorter has many options you can pass in at initialization to achieve different effects<br>
2011-07-17 15:01:18 +00:00
<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)
2011-06-22 23:19:27 +00:00
</p>
2012-03-07 18:06:35 +00:00
<table id="options" class="tablesorter options">
2011-07-17 15:01:18 +00:00
<thead>
<tr>
2011-09-16 15:43:09 +00:00
<th class="property">Property</th>
<th class="type">Type</th>
<th class="defaults">Default</th>
<th class="descrip">Description</th>
2011-08-01 03:15:17 +00:00
<th class="examples">Link</th>
2011-07-17 15:01:18 +00:00
</tr>
</thead>
2012-03-07 18:06:35 +00:00
<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>
2011-07-17 15:01:18 +00:00
<tbody>
<tr id="cancelselection">
<td>cancelSelection</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>
2012-03-27 01:49:48 +00:00
<td>"tablesorter-headerSortUp"</td>
2011-07-17 15:01:18 +00:00
<td>The CSS style used to style the header when sorting ascending. Example from the blue skin:
<div class="collapsible">
2012-03-27 01:49:48 +00:00
<pre class="css">th.tablesorter-headerSortUp {
background-color: #8dbdd8;
background-image: url(black-asc.gif);
2011-07-17 15:01:18 +00:00
}</pre></div>
</td>
<td></td>
</tr>
<tr id="csschildrow">
<td><a class="toggle" href="#">cssChildRow</a></td>
<td>String</td>
<td>"expand-child"</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.</td>
2011-11-08 03:47:46 +00:00
<td>Ex:<a href="example-child-rows.html">1</a> <a href="example-child-rows-filtered.html">2</a></td>
2011-07-17 15:01:18 +00:00
</tr>
<tr class="expand-child">
<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="html">
&lt;table width=&quot;100%&quot; border=&quot;1&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item #&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Available&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;12345&lt;/td&gt;
&lt;td&gt;Toy Car&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;expand-child&quot;&gt; &lt;!-- this row will remain attached to the above row, and not sort separately --&gt;
&lt;td colspan=&quot;3&quot;&gt;
It&#39;s a toy car!
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;23456&lt;/td&gt;
&lt;td&gt;Toy Plane&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;expand-child&quot;&gt; &lt;!-- this row will remain attached to the above row, and not sort separately --&gt;
&lt;td colspan=&quot;3&quot;&gt;
It&#39;s a toy plane!
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&quot;expand-child&quot;&gt; &lt;!-- this row will remain attached to the above two rows, and not sort separately --&gt;
&lt;td colspan=&quot;3&quot;&gt;
and it flies!
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</pre>
</td>
<td></td>
</tr>
<tr id="cssdesc">
<td><a href="#" class="toggle2">cssDesc</a></td>
<td>String</td>
2012-03-27 01:49:48 +00:00
<td>"tablesorter-headerSortDown"</td>
2011-07-17 15:01:18 +00:00
<td>The CSS style used to style the header when sorting descending. Example from the blue skin:
<div class="collapsible">
2012-03-27 01:49:48 +00:00
<pre class="css">th.tablesorter-headerSortDown {
background-color: #8dbdd8;
background-image: url(black-desc.gif);
2011-07-17 15:01:18 +00:00
}</pre></div>
</td>
<td></td>
</tr>
<tr id="cssheader">
<td><a href="#" class="toggle2">cssHeader</a></td>
<td>String</td>
2012-03-27 01:49:48 +00:00
<td>"tablesorter-header"</td>
2011-07-17 15:01:18 +00:00
<td>The CSS style used to style the header in its unsorted state. Example from the blue skin:
<div class="collapsible">
2012-03-27 01:49:48 +00:00
<pre class="css">th.tablesorter-header {
background-color: #e6eeee;
background-image: url(black-bg.gif);
2011-07-17 15:01:18 +00:00
background-repeat: no-repeat;
2012-03-27 01:49:48 +00:00
background-position: center right;
border-collapse: collapse;
cursor: pointer;
font-size: 12px;
padding: 4px 20px 4px 4px;
2011-07-17 15:01:18 +00:00
}</pre></div>
</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. <span class="tip"><em>New!</em></span> 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="html">&lt;tbody class=&quot;tablesorter-infoOnly&quot;&gt;
&lt;tr&gt;
&lt;th&gt;The contents of this tbody&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;will not be sorted&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;</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>
2012-03-07 18:06:35 +00:00
<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. <span class="tip"><em>New!</em></span> 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 class="hilight">$('table').trigger('update');</code>) those added rows will automatically become incorporated into the table.
</div>
</td>
<td></td>
</tr>
2011-07-17 15:01:18 +00:00
<tr id="dateformat">
<td><a href="#" class="toggle2">dateFormat</a></td>
<td>String</td>
2011-10-18 15:52:53 +00:00
<td>"mmddyyyy"</td>
<td>Set the date format. Here are the available options. <span class="tip"><em>Modified</em></span> in version 2.0.23.
2011-07-17 15:01:18 +00:00
<div class="collapsible">
<ul>
2011-10-18 15:52:53 +00:00
<li><code class="hilight">"mmddyyyy"</code> (default)</li>
<li><code class="hilight">"ddmmyyyy"</code></li>
<li><code class="hilight">"yyyymmdd"</code></li>
2011-07-17 15:01:18 +00:00
</ul>
2011-10-18 15:52:53 +00:00
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="js">$(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>
2011-07-17 15:01:18 +00:00
</div>
</td>
2011-10-18 15:52:53 +00:00
<td><a href="example-option-date-format.html">Example</a></td>
2011-07-17 15:01:18 +00:00
</tr>
<tr id="debug">
<td>debug</td>
<td>Boolean</td>
<td>false</td>
<td>
Boolean flag indicating if tablesorter should display debuging information usefull for development.
</td>
<td><a href="example-option-debug.html">Example</a></td>
</tr>
2012-04-20 16:09:43 +00:00
<tr id="emptyto">
<td><a href="#" class="toggle2">emptyTo</a></td>
<td>String</td>
<td>"bottom"</td>
2012-04-12 22:05:28 +00:00
<td>
2012-04-20 16:09:43 +00:00
Boolean flag indicating how tablesorter should deal with empty table cells. <span class="tip"><em>Modified!</em></span> v2.1.16.
2012-04-12 22:05:28 +00:00
<div class="collapsible">
<ul>
2012-04-20 16:09:43 +00:00
<li><code class="hilight">bottom</code> - sort empty table cells to the bottom.</li>
<li><code class="hilight">top</code> - sort empty table cells to the top.</li>
<li><code class="hilight">none</code> or <code class="hilight">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, set in order of priority:
<ul>
2012-05-07 19:22:24 +00:00
<li>jQuery data <code class="hilight">data-empty="top"</code>.</li>
2012-04-20 16:09:43 +00:00
<li>metadata <code class="hilight">class="{ empty: 'top'}"</code>. This requires the metadata plugin.</li>
<li>headers option <code class="hilight">headers : { 0 : { empty : 'top' } }</code>.</li>
<li>header class name <code class="hilight">class="empty-top"</code>.</li>
<li>Overall <code>emptyTo</code> option.</li>
2012-04-12 22:05:28 +00:00
</ul>
2012-04-20 16:09:43 +00:00
<code class="hilight">emptyToBottom</code> option was added in v2.1.11, then replaced by the <code class="hilight">emptyTo</code> option in v2.1.16.
2012-04-12 22:05:28 +00:00
</div>
</td>
<td><a href="example-option-sort-empty.html">Example</a></td>
</tr>
2011-07-17 15:01:18 +00:00
<tr id="headerlist">
<td>headerList</td>
<td>Array</td>
2012-03-27 01:49:48 +00:00
<td>[ ] (empty array)</td>
2011-07-17 15:01:18 +00:00
<td>Internal list of each header element as selected using jQuery selectors in the <a href="#selectorheaders"><code class="hilight">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 class="hilight">headers: { 0: { option: setting }, ... }</code>
<div class="collapsible">
<br>
For example, to disable sorting on the first two columns of a table: <code class="hilight">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).
2011-08-04 06:24:26 +00:00
See the full list of <a href="#parsers">default parsers</a> here or <a href="example-parsers.html">write your own</a>.
2011-07-17 15:01:18 +00:00
<pre class="js">$(function(){
$("table").tablesorter({
headers: {
2011-08-01 03:15:17 +00:00
// See example - Disable first column
0: { sorter: false },
// See example 2: Sort column numerically &amp; treat any text as if its value is:
1: { sorter: "digit" }, // zero
2: { sorter: "digit", string: "max+" }, // maximum positive value
3: { sorter: "digit", string: "max-" }, // maximum negative value
// Sort the fifth column by date (e.g. mm/dd/yyyy if the date format is "us")
2011-09-16 18:39:03 +00:00
4: { sorter: "shortDate" },
2011-08-01 03:15:17 +00:00
2011-10-18 15:52:53 +00:00
// See example 3: lock the sort order
// this option will not work if added as metadata
2011-08-01 03:15:17 +00:00
5: { lockedOrder: "asc" },
// See Example 4: Initial sort order direction of seventh column
2011-09-16 18:39:03 +00:00
6: { sortInitialOrder: "desc" },
// Set the filter to false to disable the filter widget in this column
// See the "Applying the filter widget" demo
7: { filter: false }
2011-08-01 03:15:17 +00:00
2011-07-17 15:01:18 +00:00
}
});
});</pre></div>
</td>
<td>
Ex:<a href="example-options-headers.html">1</a>
2011-08-01 03:15:17 +00:00
<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>
2011-07-17 15:01:18 +00:00
</tr>
<tr id="ignorecase">
<td>ignoreCase</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.</td>
<td></td>
</tr>
2011-07-17 15:01:18 +00:00
<tr id="onrenderheader">
<td><a href="#" class="toggle2">onRenderHeader</a></td>
<td>Function</td>
<td>null</td>
<td>
This function is called when classes are added to the TH tags. 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 span by default. In the example below, the header cell (TH) span is given a class name (<a href="http://www.pengoworks.com/workshop/jquery/tablesorter/tablesorter.htm">source</a>).
<pre class="js">$(function(){
$("table").tablesorter({
onRenderHeader: function (){
$(this).find('span').addClass('roundedCorners');
}
});
});</pre>and you'll end up with this HTML (only the thead is shown)<pre class="html">&lt;thead&gt;
&lt;tr&gt;
&lt;th class=&quot;header&quot;&gt;&lt;span class=&quot;roundedCorners&quot;&gt;Column 1&lt;/span&gt;&lt;/th&gt;
&lt;th class=&quot;header&quot;&gt;&lt;span class=&quot;roundedCorners&quot;&gt;Column 2&lt;/span&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;</pre></div>
</td>
<td><a href="example-option-render-header.html">Example</a></td>
</tr>
<tr id="parsers">
<td><a href="#" class="toggle2">parsers</a></td>
<td>Object</td>
2012-03-27 01:49:48 +00:00
<td>{ }</td>
2011-07-17 15:01:18 +00:00
<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 class="hilight">sorter: false</code></th><td>disable sort for this column.</td></tr>
<tr><th><code class="hilight">sorter: "text"</code></th><td>Sort alpha-numerically.</td></tr>
<tr><th><code class="hilight">sorter: "digit"</code></th><td>Sort numerically.</td></tr>
<tr><th><code class="hilight">sorter: "currency"</code></th><td>Sort by currency value (supports "&#163;$&#8364;&#x00a4;&#x00a5;&#x00a2;").</td></tr>
2011-07-17 15:01:18 +00:00
<tr><th><code class="hilight">sorter: "ipAddress"</code></th><td>Sort by IP Address.</td></tr>
<tr><th><code class="hilight">sorter: "url"</code></th><td>Sort by url.</td></tr>
<tr><th><code class="hilight">sorter: "isoDate"</code></th><td>Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD).</td></tr>
<tr><th><code class="hilight">sorter: "percent"</code></th><td>Sort by percent.</td></tr>
<tr><th><code class="hilight">sorter: "usLongDate"</code></th><td>Sort by date (U.S. Standard, e.g. Jan 18, 2001 9:12 AM).</td></tr>
<tr><th><code class="hilight">sorter: "shortDate"</code></th><td>Sort by a shorten date (see <a href="#dateformat"><code class="hilight">"dateFormat"</code></a>).</td></tr>
<tr><th><code class="hilight">sorter: "time"</code></th><td>Sort by time (23:59 or 12:59 pm).</td></tr>
<tr><th><code class="hilight">sorter: "metadata"</code></th><td>Sort by the sorter value in the metadata - requires the metadata plugin.</td></tr>
</tbody></table><br>
2012-03-07 18:06:35 +00:00
Check out the <a href="#headers"><code class="hilight">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).
2011-07-17 15:01:18 +00:00
</div>
</td>
2011-08-04 06:24:26 +00:00
<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>
2011-07-17 15:01:18 +00:00
</tr>
<tr id="selectorheaders">
<td>selectorHeaders</td>
<td>String</td>
<td>"thead th"</td>
<td>jQuery selectors used to find the header cells. You can change this, but the table will still need the required thead and tbody before this plugin will work properly.</td>
<td></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 <code class="hilight">sortList</code>.
<div class="collapsible">
<br>
For example, <code class="hilight">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 class="hilight">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 class="hilight">sortForce</code></a> forces the user to have this/these column(s) sorted first (null by default).</li>
<li><a href="#sortlist"><code class="hilight">SortList</code></a> is the initial sort order of the columns.</li>
<li><a href="#sortappend"><code class="hilight">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 class="hilight">[[columnIndex, sortDirection], ... ]</code> where <code class="hilight">columnIndex</code> is a zero-based index for your columns left-to-right and <code class="hilight">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 class="hilight">[[0,0],[1,0]]</code>.
<pre class="js">$(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)
});
2012-03-07 18:06:35 +00:00
});</pre></div>
2011-07-17 15:01:18 +00:00
</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 class="hilight">[[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 class="hilight">[[0,0],[1,0]]</code>. Please see <a href="#sortforce"><code class="hilight">sortForce</code></a> for more details on other sort order options.
</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 class="hilight">[[columnIndex, sortDirection], ... ]</code> where <code class="hilight">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 class="hilight">[[0,0],[1,0]]</code>. Please see <a href="#sortforce"><code class="hilight">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>sortInitialOrder</td>
<td>String</td>
<td>"asc"</td>
<td>
When clicking the header for the first time, the direction it sorts. Valid arguments are <code class="hilight">"asc"</code> for Ascending or <code class="hilight">"desc"</code> for Descending.<br>
2012-03-07 18:06:35 +00:00
This order can also be set by desired column using the <a href="#headers"><code class="hilight">headers</code></a> option (Added in v2.0.8).
</td>
<td>Ex:<a href="example-option-sort-order.html">1</a> <a href="example-options-headers-order.html">2</a></td>
2011-07-17 15:01:18 +00:00
</tr>
<tr id="sortlocalecompare">
<td><a href="#" class="toggle2">sortLocaleCompare</a></td>
2011-07-17 15:01:18 +00:00
<td>Boolean</td>
<td>false</td>
<td>
Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. <span class="tip"><em>Modified!</em></span> v2.2.
<div class="collapsible">
<ul>
<li>This option no longer switches the sort to use the <code class="hilight">String.localeCompare</code> method.</li>
<li>When this option is <code class="hilight">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 class="hilight">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 class="hilight">&#x00e1;&#x00e0;&#x00e2;&#x00e3;&#x00e4;</code> replaced with <code class="hilight">a</code></li>
<li><code class="hilight">&#x00e7;</code> replaced with <code class="hilight">c</code></li>
<li><code class="hilight">&#x00e9;&#x00e8;&#x00ea;&#x00eb;</code> replaced with <code class="hilight">e</code></li>
<li><code class="hilight">&#x00ed;&#x00ec;&#x0130;&#x00ee;&#x00ef;</code> replaced with <code class="hilight">i</code></li>
<li><code class="hilight">&#x00f3;&#x00f2;&#x00f4;&#x00f5;&#x00f6;</code> replaced with <code class="hilight">o</code></li>
<li><code class="hilight">&#x00fa;&#x00f9;&#x00fb;&#x00fc;</code> replaced with <code class="hilight">u</code></li>
<li><code class="hilight">&#x00df;</code> replaced with <code class="hilight">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 class="hilight">String.localeCompare</code> method, then set the <code class="hilight">sortLocaleCompare</code> option to <code class="hilight">false</code> and use the new <code class="hilight">textSorter</code> option as follows:
<pre class="js">$('table').tablesorter({
textSorter: function(a,b) {
return a.localeCompare(b);
}
});</pre></li>
</ul>
<del>Boolean flag indicating whenever to use javascript <code class="hilight">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>
2011-07-17 15:01:18 +00:00
</td>
<td><a href="example-locale-sort.html">Example</a></td>
2011-07-17 15:01:18 +00:00
</tr>
2012-02-01 05:14:28 +00:00
<tr id="sortreset">
<td>sortReset</td>
<td>Boolean</td>
<td>false</td>
<td>
2012-03-07 18:06:35 +00:00
Setting this option to <code class="hilight">true</code> will allow you to click on the table header a third time to reset the sort direction. New in v2.0.27.
2012-02-01 05:14:28 +00:00
</td>
<td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
2012-02-01 05:14:28 +00:00
</tr>
<tr id="sortrestart">
<td>sortRestart</td>
<td>Boolean</td>
<td>false</td>
<td>
Setting this option to <code class="hilight">true</code> will start the sort with the <code class="hilight">sortInitialOrder</code> when clicking on a previously unsorted column. New in v2.0.31.
</td>
<td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
</tr>
2011-07-17 15:01:18 +00:00
<tr id="sortmultisortkey">
<td>sortMultiSortKey</td>
<td>String</td>
<td>"shiftKey"</td>
2012-03-07 18:06:35 +00:00
<td>The key used to select more than one column for multi-column sorting. Defaults to the shift key. The other options are <code class="hilight">"ctrlKey"</code> or <code class="hilight">"altKey"</code>. Reference: <a class="external" href="http://developer.mozilla.org/en/docs/DOM:event#Properties">http://developer.mozilla.org/en/docs/DOM:event#Properties</a></td>
2011-07-17 15:01:18 +00:00
<td><a href="example-option-sort-key.html">Example</a></td>
</tr>
2012-04-20 16:09:43 +00:00
<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. <span class="tip"><em>New!</em></span> 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 class="hilight">"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 class="hilight">"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 class="hilight">"top"</code> will always sort the text to the top of the column.</li>
<li><code class="hilight">"bottom"</code> will always sort the text to the bottom of the column.</li>
<li><code class="hilight">"none"</code> or <code class="hilight">"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, set in order of priority:
<ul>
2012-05-07 19:22:24 +00:00
<li>jQuery data <code class="hilight">data-string="top"</code>.</li>
2012-04-20 16:09:43 +00:00
<li>metadata <code class="hilight">class="{ string: 'top'}"</code>. This requires the metadata plugin.</li>
<li>headers option <code class="hilight">headers : { 0 : { string : 'top' } }</code>.</li>
<li>header class name <code class="hilight">class="string-top"</code>.</li>
<li>Overall <code class="hilight">stringTo</code> option.</li>
</ul>
</div>
</td>
<td><a href="example-options-headers-digits-strings.html">Example</a></td>
</tr>
2011-11-08 03:47:46 +00:00
<tr id="tableClass">
<td>tableClass</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>
2011-07-17 15:01:18 +00:00
<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.
2012-03-11 14:45:10 +00:00
The built-in option is <code class="hilight">"simple"</code> which is the equivalent of doing this inside of the textExtraction function: <code class="hilight">$(node).text();</code>.
2011-07-17 15:01:18 +00:00
<div class="collapsible">
2011-09-16 15:43:09 +00:00
<br>
2012-03-11 14:45:10 +00:00
You can customize the text extraction by writing your own text extraction function "myTextExtraction" which you define like:
<pre class="js">var myTextExtraction = function(node, table, cellIndex){
2011-07-17 15:01:18 +00:00
// extract data from markup and return it
// originally: return node.childNodes[0].childNodes[0].innerHTML;
2012-03-11 14:45:10 +00:00
return $(node).find('selector').text();
2011-06-22 23:19:27 +00:00
}
$(function(){
2011-07-17 15:01:18 +00:00
$("#myTable").tableSorter( { textExtraction: myTextExtraction } );
});</pre>
2012-03-11 14:45:10 +00:00
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 class="hilight">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 class="hilight">table</code> and <code class="hilight">cellIndex</code> variables to the <code class="hilight">textExtraction</code> function in version 2.1.2.</p>
2011-07-17 15:01:18 +00:00
<pre class="js">$(function(){
$("table").tablesorter({
textExtraction: {
2012-03-11 14:45:10 +00:00
1: function(node, table, cellIndex) {
2011-07-17 15:01:18 +00:00
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="js">$(function(){
$("table").tablesorter({
textSorter : naturalSort
});
});</pre>
or use the localeCompare sort
<pre class="js">$(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>
2012-03-12 23:33:56 +00:00
<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: <span class="tip"><em>New!</em></span> in v2.1.3.
<div class="collapsible">
<table class="info"><tbody>
<tr>
<th><code class="hilight">true</code></th>
<td class="right">U.S.</td>
<td><code class="hilight">1,234,567.89</code></td>
</tr>
<tr>
<th><code class="hilight">false</code></th>
<td class="right">German:<br>French:</td>
<td><code class="hilight">1.234.567,89</code><br><code class="hilight">1 234 567,89</code></td>
</tr>
</tbody></table>
</div>
</td>
<td><a href="../index.html">Example</a></td>
</tr>
2011-07-17 15:01:18 +00:00
<tr id="widgets">
<td>widgets</td>
<td>Array</td>
2012-03-27 01:49:48 +00:00
<td>[ ] (empty array)</td>
2011-07-17 15:01:18 +00:00
<td>
Initialize widgets using this option ( e.g. <code class="hilight">widgets : ['zebra']</code>, or custom widgets <code class="hilight">widgets: ['zebra', 'myCustomWidget'];</code>, see <a href="example-widgets.html">this demo</a> on how to write your own custom widget ).
</td>
2011-09-11 17:51:02 +00:00
<td><a href="example-widget-zebra.html">Example</a></td>
2011-07-17 15:01:18 +00:00
</tr>
2012-03-07 18:06:35 +00:00
<tr id="widthfixed">
<td>widthFixed</td>
<td>Boolean</td>
<td>false</td>
2011-07-17 15:01:18 +00:00
<td>
2012-03-07 18:06:35 +00:00
Indicates if tablesorter should apply fixed widths to the table columns. 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.
</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>
2012-03-27 01:49:48 +00:00
<td>{ }</td>
2012-03-07 18:06:35 +00:00
<td>
As of 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. <span class="tip"><em>New!</em></span> in v2.1.
2011-07-17 15:01:18 +00:00
<div class="collapsible">
2011-09-16 15:43:09 +00:00
<br>
2012-03-07 18:06:35 +00:00
Previously documented widget options <a href="#widgetzebra"><code class="hilight">widgetZebra</code></a>, <a href="#widgetcolumns"><code class="hilight">widgetColumns</code></a> and <a href="#widgetuitheme"><code class="hilight">widgetUitheme</code></a> will be retained for backwards compatibility.<br>
<br>
Use the <a href="#widgetoptions"><code class="hilight">widgetOptions</code></a> option as follows, please note that each option is followed by a comma (except the last one):
2011-07-17 15:01:18 +00:00
<pre class="js">$(function(){
$("table").tablesorter({
2012-03-07 18:06:35 +00:00
// initialize a bunch of widgets
widgets: ["zebra", "uitheme", "columns", "filter", "stickyHeaders"],
widgetOptions: {
// zebra widget: adding zebra striping, using content and default styles - the ui css removes the background
// from default even and odd class names included for this demo to allow switching themes
// [ "even", "odd" ]
zebra : ["ui-widget-content even", "ui-state-default odd"],
// uitheme widget: change default uitheme icons
// find the full list of icons here: http://jqueryui.com/themeroller/ (hover over them for their name)
// default icons: ["ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n"]
// ["up/down arrow (cssHeaders/unsorted)","down arrow (cssDesc/descending)","up arrow (cssAsc/ascending)"]
uitheme : ["ui-icon-carat-2-n-s", "ui-icon-carat-1-s", "ui-icon-carat-1-n"],
// columns widget: change the default column class names
// primary is the first column sorted, secondary is the second, etc
columns : [ "primary", "secondary", "tertiary" ],
// filter widget: If there are child rows in the table (rows with class name from "cssChildRow" option)
// and this option is true and a match is found anywhere in the child row, then it will make that row
// visible; default is false
filter_childRows : false,
// filter widget: css class applied to the table row containing the filters & the inputs within that row
filter_cssFilter : "tablesorter-filter",
// filter widget: Set this option to true to use the filter to find text from the start of the column
// So typing in "a" will find "albert" but not "frank", both have a's; default is false
filter_startsWith : false,
2012-03-07 18:06:35 +00:00
// stickyHeaders widget: css class name applied to the sticky header
stickyHeaders : "tablesorter-stickyHeader"
}
2011-07-17 15:01:18 +00:00
});
});</pre></div>
</td>
2011-09-11 17:51:02 +00:00
<td><a href="example-widget-zebra.html">Example</a></td>
</tr>
</tbody>
2011-09-11 17:51:02 +00:00
<!-- non-sorting tbody -->
<tbody class="tablesorter-infoOnly">
<tr><th colspan="5">Deprecated Options</th></tr>
</tbody>
<tbody>
2012-03-07 18:06:35 +00:00
<tr id="widgetcolumns"> <!-- added hidden zzz to sort these deprecated options at the bottom -->
<td><span class="hidden">zzz</span><a href="#" class="toggle2 deprecated">widgetColumns</a></td>
2011-09-11 17:51:02 +00:00
<td>Object with Array</td>
2011-09-16 15:43:09 +00:00
<td>{ css:[ "primary", "secondary", "tertiary" ] }</td>
2011-09-11 17:51:02 +00:00
<td>
2012-03-07 18:06:35 +00:00
This option is being <span class="deprecated">deprecated</span>!
It has been replaced by <a href="#widget-columns"><code class="hilight">widgetOptions.columns</code></a>; but is still available for backwards compatibility.
2011-09-11 17:51:02 +00:00
<div class="collapsible">
2011-09-16 15:43:09 +00:00
<br>
2012-03-07 18:06:35 +00:00
When the column styling widget is initialized, it automatically applied the default class names of <code class="hilight">"primary"</code> for the primary sort, <code class="hilight">"secondary"</code> for the next sort, <code class="hilight">"tertiary"</code> for the next sort, and so on (add more as needed)... New in v2.0.17.
Use the <a href="#widgetcolumns"><code class="hilight">widgetColumns</code></a> option to change the css class name as follows:
2011-09-11 17:51:02 +00:00
<pre class="js">$(function(){
$("table").tablesorter({
widgets: ["columns"], // initialize column styling of the table
widgetColumns: { css: ["primary", "secondary", "tertiary" ] }
});
});</pre></div>
</td>
2012-03-07 18:06:35 +00:00
<td></td>
2011-07-17 15:01:18 +00:00
</tr>
2011-09-16 15:43:09 +00:00
<tr id="widgetuitheme">
2012-03-07 18:06:35 +00:00
<td><span class="hidden">zzz</span><a href="#" class="toggle2 deprecated">widgetUitheme</a></td>
2011-09-16 15:43:09 +00:00
<td>Object with Array</td>
2011-11-08 03:47:46 +00:00
<td>{ css: [ "ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n" ] }</td>
2011-09-16 15:43:09 +00:00
<td>
2012-03-07 18:06:35 +00:00
This option is being <span class="deprecated">deprecated</span>!
It has been replaced by <a href="#widget-uitheme"><code class="hilight">widgetOptions.uitheme</code></a>; but is still available for backwards compatibility.
2011-09-16 15:43:09 +00:00
<div class="collapsible">
<br>
2012-03-07 18:06:35 +00:00
Used when the ui theme styling widget is initialized. It automatically applies the default class names of <code class="hilight">"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code class="hilight">"ui-icon-arrowthick-1-s"</code> for the descending sort and <code class="hilight">"ui-icon-arrowthick-1-n"</code> for the ascending sort. New in v2.0.9.
2011-11-08 03:47:46 +00:00
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>
2012-03-07 18:06:35 +00:00
Use the <a href="#widgetuitheme"><code class="hilight">widgetUitheme</code></a> option to change the css class name as follows:
2011-09-16 15:43:09 +00:00
<pre class="js">$(function(){
$("table").tablesorter({
widgets: ["uitheme"], // initialize ui theme styling widget of the table
2011-10-18 15:52:53 +00:00
widgetUitheme: {
2011-11-08 03:47:46 +00:00
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)
]
2011-10-18 15:52:53 +00:00
}
2011-09-16 15:43:09 +00:00
});
2012-03-07 18:06:35 +00:00
});</pre></div>
</td>
<td></td>
</tr>
<tr id="widgetzebra">
<td><span class="hidden">zzz</span><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 class="hilight">widgetOptions.zebra</code></a>; but is still available for backwards compatibility.
2012-03-07 18:06:35 +00:00
<div class="collapsible">
<br>
When the zebra striping widget is initialized, it automatically applied the default class names of <code class="hilight">"even"</code> and <code class="hilight">"odd"</code>.
Use the <a href="#widgetzebra"><code class="hilight">widgetZebra</code></a> option to change the css class name as follows:
<pre class="js">$(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>
<p class="tip">
tablesorter widgets have many options, and to better organize them, they now are grouped together inside of the <code class="hilight">widgetOptions</code><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)
</p>
<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 class="hilight">"primary"</code> for the primary sort, <code class="hilight">"secondary"</code> for the next sort, <code class="hilight">"tertiary"</code> for the next sort, and so on (add more as needed)... <span class="tip"><em>Modified!</em></span> in v2.1.
<div class="collapsible">
<br>
Use the <a href="#widget-columns"><code class="hilight">"columns"</code></a> option to change the css class name as follows:
<pre class="js">$(function(){
$("table").tablesorter({
widgets: ["columns"], // initialize column styling of the table
widgetOptions : {
columns: [ "primary", "secondary", "tertiary" ]
}
});
2011-09-16 15:43:09 +00:00
});</pre></div>
</td>
<td><a href="example-widget-columns.html">Example</a></td>
</tr>
2012-03-07 18:06:35 +00:00
<tr id="widget-filter-childrows">
<td><a href="#" class="toggle2">filter_childRows</a></td>
2011-07-17 15:01:18 +00:00
<td>Boolean</td>
<td>false</td>
2012-03-07 18:06:35 +00:00
<td>
Filter widget: If there are child rows in the table (rows with class name from <a href="#csschildrow"><code class="hilight">"cssChildRow"</code></a> option) and this option is <code class="hilight">true</code> and a match is found anywhere in the child row, then it will make that row visible.
<span class="tip"><em>Modified!</em></span> in v2.1.
<div class="collapsible">
<br>
Use the <a href="#widget-filter-childrows"><code class="hilight">filter_childRows</code></a> option include child row text as follows:
<pre class="js">$(function(){
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_childRows : 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 the filter header row (tr) and each input within that row. If you change it from the default class name of <code class="hilight">"tablesorter-filter"</code> make sure you also update the css!
<span class="tip"><em>New!</em></span> in v2.1.
<div class="collapsible">
<br>
Use the <a href="#widget-filter-cssfilter"><code class="hilight">"tablesorter-filter"</code></a> option to change the css class name as follows:
<pre class="js">$(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-startswith">
<td><a href="#" class="toggle2">filter_startsWith</a></td>
2012-03-07 18:06:35 +00:00
<td>Boolean</td>
<td>false</td>
<td>
Filter widget: Set this option to <code class="hilight">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.
<span class="tip"><em>New!</em></span> in v2.1.
<div class="collapsible">
<br>
Use the <a href="#widget-filter-startswith"><code class="hilight">filter_startsWith</code></a> option as follows:
2012-03-07 18:06:35 +00:00
<pre class="js">$(function(){
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_startsWith : true
2012-03-07 18:06:35 +00:00
}
});
});</pre></div>
</td>
<td><a href="example-widget-filter.html">Example</a></td>
</tr>
<tr id="widget-sticky-headers">
<td><a href="#" class="toggle2">stickyHeaders</a></td>
<td>String</td>
<td>'tablesorter-stickyHeader'</td>
<td>
stickyHeaders widget: This is the class name applied to the sticky header row (tr). If you change it from the default class name of <code class="hilight">"tablesorter-stickyHeader"</code> make sure you also update the css!
<span class="tip"><em>New!</em></span> in v2.1.
<div class="collapsible">
<br>
Use the <a href="#widget-sticky-headers"><code class="hilight">"stickyHeaders"</code></a> option to change the css class name as follows:
<pre class="js">$(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-uitheme">
<td><a href="#" class="toggle2">uitheme</a></td>
<td>Array</td>
<td>[ "ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n" ]</td>
<td>
uitheme widget: This widget option replaces the previous <a href="#widgetuitheme">widgetUitheme</a>. It is used when the ui theme styling widget is initialized. It automatically applies the default class names of <code class="hilight">"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code class="hilight">"ui-icon-arrowthick-1-s"</code> for the descending sort and <code class="hilight">"ui-icon-arrowthick-1-n"</code> for the ascending sort. <span class="tip"><em>Modified!</em></span> in v2.1.
<div class="collapsible">
<br>
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 class="hilight">"widgetUitheme"</code></a> option to change the css class name as follows:
<pre class="js">$(function(){
$("table").tablesorter({
widgets: ["uitheme"], // initialize ui theme styling widget of the table
widgetOptions: {
uitheme : [
"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><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 class="hilight">"even"</code> and <code class="hilight">"odd"</code>. <span class="tip"><em>Modified!</em></span> in v2.1.
<div class="collapsible">
<br>
Use the <a href="#widget-zebra"><code class="hilight">"zebra"</code></a> option to change the css class name as follows:
<pre class="js">$(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>
2011-07-17 15:01:18 +00:00
</tr>
</tbody>
</table>
2012-03-07 18:06:35 +00:00
<a id="Methods"></a>
2011-07-17 15:01:18 +00:00
<h1>Methods</h1>
<p class="tip">
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):
</p>
2012-03-07 18:06:35 +00:00
<table id="methods" class="tablesorter">
2011-07-17 15:01:18 +00:00
<thead>
<tr>
<th>Method</th>
<th>Description</th>
<th>Link</th>
</tr>
</thead>
<tbody>
2011-09-08 16:28:10 +00:00
<tr id="addrows">
<td><a href="#" class="toggle2">addRows</a></td>
2012-03-07 18:06:35 +00:00
<td>Use this method to add table rows. New in v2.0.16
2011-09-08 16:28:10 +00:00
<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="js">// Add multiple rows to the table
2011-10-18 15:52:53 +00:00
var row = '&lt;tr&gt;&lt;td&gt;Inigo&lt;/td&gt;&lt;td&gt;Montoya&lt;/td&gt;&lt;td&gt;34&lt;/td&gt;' +
'&lt;td&gt;$19.99&lt;/td&gt;&lt;td&gt;15%&lt;/td&gt;&lt;td&gt;Sep 25, 1987 12:00PM&lt;/td&gt;&lt;/tr&gt;',
2012-04-24 03:16:06 +00:00
$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.
resort = true;
2011-09-08 16:28:10 +00:00
$('table')
.find('tbody').append($row)
2012-04-24 03:16:06 +00:00
.trigger('addRows', [$row, resort]);</pre></div>
2011-09-08 16:28:10 +00:00
</td>
<td><a href="example-add-rows.html">Example</a></td>
</tr>
2011-07-17 15:01:18 +00:00
<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="js">// Choose a new sort order
var sort = [[0,0],[2,0]];
// Note that the sort value below is inside of another array (inside another set of square brackets)
$("table").trigger("sorton", [sort]);</pre></div>
</td>
<td><a href="example-trigger-sort.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="js">// Add new content
$("table tbody").append(html);
// let the plugin know that we made a update
2012-04-24 03:16:06 +00:00
// the resort flag set to anything BUT false (no quotes) will trigger an automatic
// table resort using the current sort
var resort = true;
$("table").trigger("update", [resort]);
2011-07-17 15:01:18 +00:00
2011-08-22 15:08:34 +00:00
// 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
2011-07-17 15:01:18 +00:00
// 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="js">// Table data was just dynamically changed (more than one cell)
$("table")
2011-07-17 15:01:18 +00:00
.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="js">$(function() {
$("table").tablesorter();
$("td.discount").click(function(){
// randomize a number
2012-04-24 03:16:06 +00:00
var resort = false,
discount = '$' + Math.round(Math.random() * Math.random() * 100) + '.' +
2011-10-18 15:52:53 +00:00
('0' + Math.round(Math.random() * Math.random() * 100)).slice(-2);
2011-07-17 15:01:18 +00:00
$(this).text(discount);
// update the table, so the tablesorter plugin knows its value
2012-04-24 03:16:06 +00:00
// 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]);
2011-07-17 15:01:18 +00:00
2011-08-22 15:08:34 +00:00
// 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
2011-07-17 15:01:18 +00:00
// set sorting column and direction, this will sort on the first and third column
var sorting = [[3,1]];
2012-04-24 03:16:06 +00:00
$("table").trigger("sorton", [sorting]);
2011-07-17 15:01:18 +00:00
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="js">$(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="js">// Update the list of widgets to apply to the table (add or remove)
$("table").data("tablesorter").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>
</tbody>
</table>
2012-03-07 18:06:35 +00:00
<a id="Events"></a>
2011-07-17 15:01:18 +00:00
<h1>Events</h1>
<p class="tip">
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):
</p>
2012-03-07 18:06:35 +00:00
<table id="events" class="tablesorter">
2011-07-17 15:01:18 +00:00
<thead>
<tr>
<th>Event</th>
<th>Description</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<tr id="sortstart">
<td><a href="#" class="toggle2">sortStart</a></td>
<td>This event fires when tablesorter is about to start resorting the table.
<div class="collapsible">
<pre class="js">$(function(){
// initialize the tablesorter plugin
$("table").tablesorter();
// bind to sort events
$("table")
.bind("sortStart",function() {
$("#overlay").show();
})
.bind("sortEnd",function() {
$("#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="js">$(function(){
// initialize the tablesorter plugin
$("table").tablesorter();
// bind to sort events
$("table")
.bind("sortStart",function() {
$("#overlay").show();
})
.bind("sortEnd",function() {
$("#overlay").hide();
});
});</pre></div>
</td>
<td><a href="example-triggers.html">Example</a></td>
</tr>
<tr id="pagerChange">
<td><a href="#" class="toggle2">pagerChange</a></td>
2012-03-07 18:06:35 +00:00
<td>This event fires when the pager plugin begins to render the table on the currently selected page. New in v2.0.7.
2011-07-17 15:01:18 +00:00
<div class="collapsible">
<pre class="js">$(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>
2012-03-07 18:06:35 +00:00
<td>This event fires when the pager plugin has completed its render of the table on the currently selected page. New in v2.0.7.
2011-07-17 15:01:18 +00:00
<div class="collapsible">
<pre class="js">$(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>
</tbody>
</table>
2012-03-07 18:06:35 +00:00
<a id="Download"></a>
2011-06-22 23:19:27 +00:00
<h1>Download</h1>
2011-07-17 15:01:18 +00:00
2012-04-23 19:24:45 +00:00
<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>
2011-07-17 15:01:18 +00:00
2011-06-22 23:19:27 +00:00
<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>
2011-07-17 15:01:18 +00:00
2011-06-22 23:19:27 +00:00
<strong id="Download-Required">Required:</strong>
<ul>
2012-03-21 00:50:53 +00:00
<li><a class="external" href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery">jQuery</a> (1.2.6 or higher; some demos need jQuery 1.4.2+)</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>
2011-07-17 15:01:18 +00:00
</ul>
2011-10-15 14:58:44 +00:00
<strong id="Download-Addons">Optional / Add-Ons:</strong>
2011-06-22 23:19:27 +00:00
<ul>
2012-03-27 01:49:48 +00:00
<li><a class="external" href="http://plugins.jquery.com/files/jquery.metadata.2.1.zip">jQuery Metadata 2.1</a> (6kb, required for setting <a href="#Examples">inline options</a>)</li>
<li><a href="../js/jquery.tablesorter.js">jquery.tablesorter.js</a> (35kb/<a href="../js/jquery.tablesorter.min.js">19kb min</a>)</li>
2012-03-21 00:50:53 +00:00
<li><a href="../addons/pager/jquery.tablesorter.pager.js">jquery.tablesorter.pager.js</a> (14kb/<a href="../addons/pager/jquery.tablesorter.pager.min.js">7kb min</a>, <a href="example-pager.html">demo</a>)</li>
<li><a href="../js/jquery.tablesorter.widgets.js">jquery.tablesorter.widgets.js</a> (16kb/<a href="../js/jquery.tablesorter.widgets.min.js">8kb min</a>, includes the jQuery UI theme, columns styling, resizable columns, filter, sticky header and save sort widgets. <span class="tip"><em>Updated!</em></span> in v2.1.)</li>
2011-07-17 15:01:18 +00:00
</ul>
2011-06-22 23:19:27 +00:00
<strong id="Download-Themes">Themes:</strong>
<ul>
<li><a href="../css/green/green.zip">Green Skin</a> - Images and CSS styles for green themed headers</li>
<li><a href="../css/blue/blue.zip">Blue Skin</a> - Images and CSS styles for blue themed headers (as seen in the examples)</li>
2012-03-07 18:06:35 +00:00
<li><a href="example-widget-ui-theme.html">jQuery UI Theme</a> - Apply any jQuery UI theme to the table using the "uitheme" widget code. New in v2.0.9!</li>
2011-07-17 15:01:18 +00:00
</ul>
2012-03-07 18:06:35 +00:00
<a id="Compatibility"></a>
2011-07-17 15:01:18 +00:00
<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>
2012-03-07 18:06:35 +00:00
<a id="Support"></a>
2011-07-17 15:01:18 +00:00
<h1>Support</h1>
2011-10-15 14:58:44 +00:00
<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>
2012-03-03 01:38:02 +00:00
<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>
2011-10-15 14:58:44 +00:00
<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>
2011-07-17 15:01:18 +00:00
2012-03-07 18:06:35 +00:00
<a id="Credits"></a>
2011-07-17 15:01:18 +00:00
<h1>Credits</h1>
2012-03-03 01:38:02 +00:00
<p>Written by Christian Bach.</p>
2011-07-17 15:01:18 +00:00
<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>
2011-10-11 06:15:23 +00:00
Missing documentation, alphanumeric sort, numerous widgets and other changes added by <a class="external" href="https://github.com/Mottie/tablesorter">Mottie</a>.
2011-07-17 15:01:18 +00:00
</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>
2011-06-22 23:19:27 +00:00
</div>
</body>
</html>