Debian Codegraph @

docs/index.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0</title>
6
7 <!-- Demo stuff -->
8 <style>
9 #banner h1 em {color:#6cf;}
10 .main-nav {display:none;}
11 </style>
12 <link href="css/bootstrap-v4.min.css" rel="stylesheet">
13 <link href="css/jquery-ui.min.css" class="ui-theme" rel="stylesheet">
14
15 <link href="css/jq.css" rel="stylesheet">
16 <link href="css/menu.css" rel="stylesheet">
17 <link href="css/prettify.css" rel="stylesheet">
18 <link href="../css/theme.blue.css" rel="stylesheet">
19
20 </head>
21 <body id="root">
22
23 <input type="checkbox" class="main-nav-check" id="main-nav-check" />
24 <div class="main-nav" id="main-nav">
25 <div class="page-search">
26 <h2 class="title">table<em>sorter</em></h2>
27 <div class="input-group search-group">
28 <div class="status"></div>
29 <input type="text" placeholder="Find on page..." size="25" maxlength="25" class="search form-control input-sm">
30 <div class="input-group-btn">
31 <button type="button" class="search-clear btn btn-default tooltip-top" title="Clear search">
32 <span class="glyphicon glyphicon-remove"></span>
33 </button>
34 <button type="button" class="search-prev btn btn-default tooltip-top" title="Previous result">
35 <span class="glyphicon glyphicon-chevron-up"></span>
36 </button>
37 <button type="button" class="search-next btn btn-default tooltip-top" title="Next search">
38 <span class="glyphicon glyphicon-chevron-down"></span>
39 </button>
40 </div>
41 </div>
42 <div class="search-options input-group-btn">
43 <div class="switch">
44 <input type="radio" class="switch-input" name="view" value="Word" id="word" checked="checked">
45 <label for="word" class="switch-label switch-label-off tooltip-edge-left" title="Search for whole word only">Word</label>
46 <input type="radio" class="switch-input" name="view" value="letter" id="letter">
47 <label for="letter" class="switch-label switch-label-on tooltip-bottom" title="Search for letters">Letter</label>
48 <span class="switch-selection btn-primary"></span>
49 </div>
50 <div class="switch">
51 <input type="radio" class="switch-input" name="view2" value="Ab" id="cstrue">
52 <label for="cstrue" class="switch-label switch-label-off tooltip-bottom" title="Case-Sensitive search">Ab</label>
53 <input type="radio" class="switch-input" name="view2" value="aa" id="csfalse" checked="checked">
54 <label for="csfalse" class="switch-label switch-label-on tooltip-edge-right" title="Case-Insensitive search">ab</label>
55 <span class="switch-selection btn-primary"></span>
56 </div>
57 <a href="https://github.com/Mottie/tablesorter/wiki/Search" class="tooltip-right glyphicon glyphicon-question-sign" title="Get search instructions">
58 </a>
59 </div>
60 </div>
61 <div class="page-links">
62 <a href="#Introduction">Introduction</a>
63 <a href="#Demo">Demo</a>
64 <a href="#Getting-Started">Getting started</a>
65 <a href="#Examples">Examples</a>
66 <a href="#Configuration">Configuration</a>
67 <a href="#Widget-options">Widget &amp; Pager Options</a>
68 <a href="#methods">Methods</a>
69 <a href="#events">Events</a>
70 <a href="#api">API</a>
71 <a href="#Download">Download</a>
72 <a href="#Compatibility">Compatibility</a>
73 <a href="#Support">Support</a>
74 <a href="#Credits">Credits</a>
75 </div>
76 </div>
77
78 <label for="main-nav-check" class="tooltip-right toggle-menu main-header" onclick="" title="Click to toggle the side menu">
79 <span></span>
80 </label>
81
82 <div id="main">
83
84 <div id="banner">
85 <h1>table<em>sorter</em> <small>(unofficial fork)</small></h1>
86 <h2>Documentation</h2>
87 <h3>Flexible client-side table sorting</h3>
88 </div>
89
90 <p>
91 <strong>Original Author:</strong> Christian Bach<br>
92 <strong>Maintainer of this fork:</strong> Rob Garrison (Mottie)<br>
93 <strong>Version:</strong> <a class="current-version" href="https://github.com/Mottie/tablesorter/archive/master.zip">2.1+</a> (<a href="https://github.com/Mottie/tablesorter/wiki/Changes">changelog</a>)&nbsp;
94 <iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=mottie&repo=tablesorter&type=fork&count=true" width="90" height="20" title="Fork on GitHub"></iframe>
95 <iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=mottie&repo=tablesorter&type=watch&count=true" width="100" height="20" title="Star on GitHub"></iframe>
96 <br>
97 <strong>Licence:</strong>
98 Dual licensed under <a class="external" href="http://www.opensource.org/licenses/mit-license.php">MIT</a>
99 or <a class="external" href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses (pick one).<br>
100 </p>
101
102 <a id="Contents"></a>
103 <h1>Contents</h1>
104 <ol>
105 <li><a href="#Introduction">Introduction</a></li>
106 <li><a href="#Demo">Demo</a></li>
107 <li><a href="#Getting-Started">Getting started</a></li>
108 <li><a href="#Examples">Examples</a></li>
109 <li><a href="#Configuration">Configuration</a></li>
110 <li><a href="#Widget-options">Widget &amp; Pager Options</a> (v2.1)</li>
111 <li><a href="#methods">Methods</a></li>
112 <li><a href="#events">Events</a></li>
113 <li><a href="#api">API</a></li>
114 <li><a href="#Download">Download</a></li>
115 <li><a href="#Compatibility">Compatibility</a></li>
116 <li><a href="#Support">Support</a></li>
117 <li><a href="#Credits">Credits</a></li>
118 </ol>
119
120 <a id="Introduction"></a>
121 <h1>Introduction</h1>
122 <p>
123 tablesorter is a <a class="external" href="http://jquery.com">jQuery</a> plugin for turning a
124 standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes.
125 tablesorter can successfully parse and sort many types of data including linked data in a cell.
126 It has many useful features including:
127 </p>
128
129 <ul>
130 <li>Multi-column sorting</li>
131 <li>Multi-tbody sorting - see the <a href="#options">options</a> table below</li>
132 <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>
133 <li>Support secondary &quot;hidden&quot; sorting (e.g., maintain alphabetical sort when sorting on other criteria)</li>
134 <li>Extensibility via <a href="example-widgets.html">widget system</a></li>
135 <li>Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+</li>
136 <li>Works with jQuery 1.2.6+ (jQuery 1.4.1+ needed with some widgets).</li>
137 <li>Works with jQuery 1.9+ ($.browser.msie was removed; needed in the original version).</li>
138 <li>Small code size</li>
139 </ul>
140
141 <a id="Demo"></a>
142 <h1>Demo</h1>
143
144 <table id="tablesorter-demo" class="tablesorter-blue">
145 <thead>
146 <tr>
147 <th>Account #</th>
148 <th>First Name</th>
149 <th>Last Name</th>
150 <th>Age</th>
151 <th>Total</th>
152 <th>Discount</th>
153 <th>Difference</th>
154 <th>Date</th>
155 </tr>
156 </thead>
157 <tbody>
158 <tr>
159 <td>A42b</td>
160 <td>Peter</td>
161 <td>Parker</td>
162 <td>28</td>
163 <td>$9.99</td>
164 <td>20.9%</td>
165 <td>+12.1</td>
166 <td>Jul 6, 2006 8:14 AM</td>
167 </tr>
168 <tr>
169 <td>A255</td>
170 <td>Bruce</td>
171 <td>Jones</td>
172 <td>33</td>
173 <td>$13.19</td>
174 <td>25%</td>
175 <td>+12</td>
176 <td>Dec 10, 2002 5:14 AM</td>
177 </tr>
178 <tr>
179 <td>A33</td>
180 <td>Clark</td>
181 <td>Evans</td>
182 <td>18</td>
183 <td>$15.89</td>
184 <td>44%</td>
185 <td>-26</td>
186 <td>Jan 12, 2003 11:14 AM</td>
187 </tr>
188 <tr>
189 <td>A1</td>
190 <td>Bruce</td>
191 <td>Almighty</td>
192 <td>45</td>
193 <td>$153.19</td>
194 <td>44.7%</td>
195 <td>+77</td>
196 <td>Jan 18, 2001 9:12 AM</td>
197 </tr>
198 <tr>
199 <td>A102</td>
200 <td>Bruce</td>
201 <td>Evans</td>
202 <td>22</td>
203 <td>$13.19</td>
204 <td>11%</td>
205 <td>-100.9</td>
206 <td>Jan 18, 2007 9:12 AM</td>
207 </tr>
208 <tr>
209 <td>A42a</td>
210 <td>Bruce</td>
211 <td>Evans</td>
212 <td>22</td>
213 <td>$13.19</td>
214 <td>11%</td>
215 <td>0</td>
216 <td>Jan 18, 2007 9:12 AM</td>
217 </tr>
218 </tbody>
219 </table>
220
221 <p class="tip">
222 <span class="label label-info">TIP!</span> Sort multiple columns simultaneously by holding down the <kbd>Shift</kbd> key and clicking a second, third or even fourth column header!
223 </p>
224
225 <a id="Getting-Started"></a>
226 <h1>Getting started</h1>
227 <p>
228 To use the tablesorter plugin, include the <a class="external" href="http://jquery.com">jQuery</a>
229 library and the tablesorter plugin inside the <code>&lt;head&gt;</code> tag
230 of your HTML document:
231 </p>
232
233 <pre class="prettyprint lang-html">&lt;!-- choose a theme file --&gt;
234 &lt;link rel=&quot;stylesheet&quot; href=&quot;/path/to/theme.default.css&quot;&gt;
235 &lt;!-- load jQuery and tablesorter scripts --&gt;
236 &lt;script type=&quot;text/javascript&quot; src=&quot;/path/to/jquery-latest.js&quot;&gt;&lt;/script&gt;
237 &lt;script type=&quot;text/javascript&quot; src=&quot;/path/to/jquery.tablesorter.js&quot;&gt;&lt;/script&gt;
238
239 &lt;!-- tablesorter widgets (optional) --&gt;
240 &lt;script type=&quot;text/javascript&quot; src=&quot;/path/to/jquery.tablesorter.widgets.js&quot;&gt;&lt;/script&gt;
241 </pre>
242
243 <p>tablesorter works on standard HTML tables. <strong>You must include THEAD and TBODY tags</strong>:</p>
244
245 <pre class="prettyprint lang-html">&lt;table id="myTable" class="tablesorter"&gt;
246 &lt;thead&gt;
247 &lt;tr&gt;
248 &lt;th&gt;Last Name&lt;/th&gt;
249 &lt;th&gt;First Name&lt;/th&gt;
250 &lt;th&gt;Email&lt;/th&gt;
251 &lt;th&gt;Due&lt;/th&gt;
252 &lt;th&gt;Web Site&lt;/th&gt;
253 &lt;/tr&gt;
254 &lt;/thead&gt;
255 &lt;tbody&gt;
256 &lt;tr&gt;
257 &lt;td&gt;Smith&lt;/td&gt;
258 &lt;td&gt;John&lt;/td&gt;
259 &lt;td&gt;[email protected]&lt;/td&gt;
260 &lt;td&gt;$50.00&lt;/td&gt;
261 &lt;td&gt;http://www.jsmith.com&lt;/td&gt;
262 &lt;/tr&gt;
263 &lt;tr&gt;
264 &lt;td&gt;Bach&lt;/td&gt;
265 &lt;td&gt;Frank&lt;/td&gt;
266 &lt;td&gt;[email protected]&lt;/td&gt;
267 &lt;td&gt;$50.00&lt;/td&gt;
268 &lt;td&gt;http://www.frank.com&lt;/td&gt;
269 &lt;/tr&gt;
270 &lt;tr&gt;
271 &lt;td&gt;Doe&lt;/td&gt;
272 &lt;td&gt;Jason&lt;/td&gt;
273 &lt;td&gt;[email protected]&lt;/td&gt;
274 &lt;td&gt;$100.00&lt;/td&gt;
275 &lt;td&gt;http://www.jdoe.com&lt;/td&gt;
276 &lt;/tr&gt;
277 &lt;tr&gt;
278 &lt;td&gt;Conway&lt;/td&gt;
279 &lt;td&gt;Tim&lt;/td&gt;
280 &lt;td&gt;[email protected]&lt;/td&gt;
281 &lt;td&gt;$50.00&lt;/td&gt;
282 &lt;td&gt;http://www.timconway.com&lt;/td&gt;
283 &lt;/tr&gt;
284 &lt;/tbody&gt;
285 &lt;/table&gt;</pre>
286
287 <p>Start by telling tablesorter to sort your table when the document is loaded:</p>
288
289 <pre class="prettyprint lang-js">$(function() {
290 $("#myTable").tablesorter();
291 });</pre>
292
293 <p>
294 Click on the headers and you'll see that your table is now sortable! You can
295 also pass in configuration options when you initialize the table. This tells
296 tablesorter to sort on the first and second column in ascending order.
297 </p>
298
299 <pre class="prettyprint lang-js">$(function() {
300 $("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
301 });</pre>
302
303 <p class="tip">
304 <span class="label label-info">NOTE!</span> tablesorter will auto-detect most data types including numbers, dates, ip-addresses for more information see <a href="#Examples">Examples</a>.
305 </p>
306
307 <a id="Examples"></a>
308 <h1>Examples</h1>
309 <p>
310 These examples will show what's possible with tablesorter. You need Javascript enabled to
311 run these samples, just like you and your users will need Javascript enabled to use tablesorter.
312 </p>
313
314 <div class="box">
315 <h3>Basic</h3>
316 <h4>Sorting</h4>
317 <ul>
318 <li>Initial:
319 <ul>
320 <li><a href="example-option-sort-list.html">Table sort</a> (<a href="#sortlist"><code>sortList</code></a>).</li>
321 <li>Sort direction (using <a href="#sortinitialorder"><code>sortInitialOrder</code></a> option [<a href="example-option-sort-order.html">demo</a>], or <a href="example-options-headers-order.html">other methods</a>).</li>
322 </ul>
323 </li>
324 <li>Prevent or reset a sort:
325 <ul>
326 <li><a href="example-option-sortreset-sortrestart.html">Using sortReset &amp; sortRestart options</a> (<a href="#sortreset"><code>sortReset</code></a> &amp; <a href="#sortrestart"><code>sortRestart</code></a>).</li>
327 <li><a href="example-method-sortreset.html">Resetting the entire table sort</a> (<a href="#sortreset-method"><code>sortReset</code></a> method; v2.4.7).</li>
328 <li><a href="example-options-headers-locked.html">Lock sort order</a>.</li>
329 <li><a href="example-options-headers.html">Disable sort for a column</a> (<span class="version updated">v2.18.1</span>).</li>
330 <li><a href="example-widget-column-selector.html">Disable sort for an entire row</a> (<a href="#cssignorerow"><code>cssIgnoreRow</code></a> class; v2.18.4).</li>
331 </ul>
332 </li>
333 <li>Modify a sort:
334 <ul>
335 <li><a href="example-option-sort-force.html">Force a default sorting order</a> (<a href="#sortforce"><code>sortForce</code></a>).</li>
336 <li><a href="example-option-sort-append.html">Append a sort to the selected sorting order</a> (<a href="#sortappend"><code>sortAppend</code></a>; <span class="version updated">v2.24.0</span>).</li>
337 <li><a href="example-option-sort-empty.html">Sorting empty cells</a> (<a href="#emptyto"><code>emptyTo</code></a>; v2.1.11).</li>
338 </ul>
339 </li>
340 <li>How to:
341 <ul>
342 <li><a href="example-option-selectorsort.html">Using selectorSort option</a> (<a href="#selectorsort"><code>selectorSort</code></a>; v2.4).</li>
343 <li><a href="example-option-sort-key.html">Change the default multi-sorting key</a> (<a href="#sortmultisortkey"><code>sortMultiSortKey</code></a>).</li>
344 <li><a href="example-option-custom-sort.html">Custom sort script</a> (<a href="#textsorter"><code>textSorter</code></a>; added v2.2; updated <span class="version updated">v2.12</span>).</li>
345 <li><a href="example-locale-sort.html">Sorting Accented Characters</a> (<a href="#sortlocalecompare"><code>sortLocaleCompare</code></a>; v2.24; <a href="https://github.com/Mottie/tablesorter/wiki/Language">languages</a>).</li>
346 <li><a href="example-trigger-sort.html">Sort table using a link outside the table</a> (external link; <span class="updated version">v2.17.0</span>).</li>
347 <li><a href="example-child-rows.html">Attach child rows (rows that sort with their parent row)</a> (<span class="updated version">v2.15.12</span>).</li>
348 <li><a href="example-child-rows-filtered.html">Use child rows + filter widget</a> (<span class="updated version">v2.22.0</span>).</li>
349 <li><a href="example-multiple-tbodies.html">Sorting with Multiple Tbodies</a> (v2.2).</li>
350 <li><a href="example-header-column-span.html">Sorting Across Multiple Columns</a> (v2.3).</li>
351 <li><a href="example-option-show-processing.html">Show a processing icon during sorting/filtering</a> (v2.4).</li>
352 <li><a href="example-option-delay-init.html">Delay table initialization</a> (<a href="#delayinit"><code>delayInit</code></a>).</li>
353 <li><a href="example-colspan.html">Sort &amp; filter with colspans</a> (<a href="#duplicatecolspan"><code>duplicateSpan</code></a>; <span class="version">v2.25.0</span>).</li>
354 </ul>
355 </li>
356 </ul>
357
358 <h4>Theming</h4>
359 <ul>
360 <li>The <a href="example-option-theme-bootstrap-v2.html">Bootstrap v2.x</a>, <a href="example-option-theme-bootstrap-v3.html">Bootstrap v3.x</a> &amp; <a href="example-widget-ui-theme.html">jQuery UI</a> themes require the uitheme widget.</li>
361 <li>The <a href="example-option-theme-bootstrap-v4.html">Bootstrap v4.x</a> theme (<span class="version">v2.28.4</span>; <span class="version updated">2.30.7</span>) does not require the uitheme widget!</li>
362 <li>Set up a <a href="example-option-theme-metro-style.html">Metro style theme</a> (<span class="version">v2.16.4</span>).</li>
363 <li>Set up a <a href="example-option-theme-materialize.html">Materialize theme</a> (<span class="version">v2.27.0</span>; <span class="version updated">v2.30.7</span>).</li>
364 <li>Use css to <a href="example-css-highlighting.html">highlight rows &amp; columns</a> (<span class="version">v2.20.0</span>); css file added (<span class="version">v2.28.6</span>).</li>
365 <li>See all <a href="themes.html">available themes</a> (<span class="version updated">v2.30.7</span>).</li>
366 </ul>
367 <p></p>
368
369 <h4>Using Parsers / Extracting Content</h4>
370 <ul>
371 <li><a href="example-option-built-in-parsers.html">Built-in parsers</a>(full list)</li>
372 <li><a href="example-option-digits.html">Dealing with digits!</a></li>
373 <li><a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> (<a href="#stringto"><code>stringTo</code></a>; v2.0.10).</li>
374 <li><a href="example-parsers-class-name.html">Disable sorting or set the column parser using class names</a> (v2.0.11).</li>
375 <li><a href="example-parsers-jquery-data.html">Disable sorting or set the column parser using data</a> (v2.3).</li>
376 <li><a href="example-options-headers-parser.html">Disable parsing of column content</a> (<span class="version">v2.17.1</span>).</li>
377 <li><a href="example-extractors-parsers.html">Using extractors with parsers</a> (<span class="version">v2.17.6</span>).</li>
378 <li><a href="example-option-date-format.html">Changing the date format</a> (v2.0.23).</li>
379 </ul>
380
381 <br/>
382 <h3>Advanced</h3>
383
384 <h4>Parsers / Extracting Content</h4>
385 <ul>
386 <li><a href="example-parsers.html">Parser, writing your own</a> (<a href="#function-addparser"><code>addParser</code></a>; <span class="updated version">v2.18.0</span>; <span class="version updated">v2.18.0</span>).</li>
387 <li><a href="example-parsers-advanced.html">Parser, writing your own, advanced use</a> (v2.1; <span class="updated version">v2.18.0</span>).</li>
388 <li><a href="example-option-text-extraction.html">Dealing with markup inside cells</a> (<a href="#textextraction"><code>textExtraction</code></a> function).</li>
389 <li><a href="example-options-headers-parser.html">Skip the parsing of column content</a> (<span class="version">v2.17.1</span>).</li>
390 </ul>
391
392 <h4>Widgets / Plugins</h4>
393 <ul>
394 <li><a href="example-apply-widget.html">Applying widgets</a></li>
395 <li><a href="example-widgets.html">Widgets, writing your own</a> (<a href="#function-addwidget"><code>addWidget</code></a>).</li>
396 <li><a href="example-pager-ajax.html">Pager plugin - ajax</a> (v2.1; <span class="version updated">v2.18.0</span>).</li>
397 <li><a href="example-pager-filtered.html">Pager plugin + filter widget</a> (v2.4).</li>
398 </ul>
399
400 <h4>Adding / Removing Content</h4>
401 <ul>
402 <li><a href="example-empty-table.html">Initializing tablesorter on a empty table</a>.</li>
403 <li><a href="example-ajax.html">Appending table data with ajax</a> (<a href="#update"><code>update</code></a>).</li>
404 <li><a href="example-add-rows.html">Adding a table row</a> (<a href="#addrows"><code>addRows</code></a>; v2.0.16).</li>
405 <li><a href="example-update-all.html">Update an entire table column (<code>thead</code> and <code>tbody</code>)</a> (<a href="#updateall"><code>updateAll</code></a>; <span class="version">v2.8</span>).</li>
406 <li><a href="example-update-cell.html">Update the table after cell content has changed</a> (<a href="#updatecell"><code>updateCell</code></a>).</li>
407 <li><a href="example-pager.html">Pager plugin</a> - examples of how to add and remove rows.</li>
408 </ul>
409
410 <h4>Change Header Style</h4>
411 <ul>
412 <li><a href="example-widget-ui-theme.html">UITheme widget</a> (v2.0.9; <span class="version updated">v2.27.0</span>).</li>
413 <li><a href="example-option-render-header.html">Modifying the Header during rendering</a> (<a href="#onrenderheader"><code>onRenderHeader</code></a>).</li>
414 <li><a href="example-option-render-template.html">Modifying the Header using a template</a> (<a href="#headertemplate"><code>headerTemplate</code></a>; v2.7).</li>
415 </ul>
416
417 <br/>
418 <h3>Other</h3>
419
420 <h4>Options &amp; Events</h4>
421 <ul>
422 <li><a href="example-triggers.html">Triggers sortEnd and sortStart (Displaying sorting progress)</a>.</li>
423 <li><a href="example-extending-defaults.html">Extending default options</a>.</li>
424 <li><a href="example-option-debug.html">Enabling debug mode</a> (<a href="#debug"><code>debug</code></a>).</li>
425 </ul>
426
427 <h4 id="metadata">Metadata - setting inline options</h4>
428 <ul>
429 <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>
430 <li><a href="example-meta-sort-list.html">Set a initial sorting order using metadata</a>.</li>
431 <li><a href="example-meta-headers.html">Disable header using metadata</a>.</li>
432 <li><a href="example-meta-parsers.html">Setting column parser using metadata</a>.</li>
433 </ul>
434
435 </div>
436
437 <div class="box">
438
439 <h3 id="demos">Demos</h3>
440
441 <h4>Playgrounds & Other demos</h4>
442 <ul>
443 <li><a href="http://jsfiddle.net/Mottie/bbxxomhx/">tablesorter basic demo</a> (includes widgets).</li>
444 <li><a href="http://jsfiddle.net/Mottie/dn1r0cy7/">tablesorter basic demo using jQuery UI theme</a>.</li>
445 <li><a href="http://jsfiddle.net/Mottie/wty134u7/">tablesorter basic demo with pager plugin</a>.</li>
446 <li>LESS themes (modify the colors in these demos dynamically):
447 <ul>
448 <li><a href="http://codepen.io/Mottie/pen/eqBbn">tablesorter LESS theme</a>.</li>
449 <li><a href="http://codepen.io/Mottie/pen/Ltzpi">tablesorter Bootstrap LESS theme</a> (<span class="version">v2.16.4</span>).</li>
450 <li><a href="http://codepen.io/Mottie/pen/gCslk">tablesorter Metro LESS theme</a> (<span class="version">v2.16.4</span>).</li>
451 <li><a href="http://codepen.io/Mottie/pen/LbXdNR">tablesorter SCSS theme</a> (<span class="version">v2.28.2</span>).</li>
452 </ul>
453 </li>
454 <li>Check out the <a href="https://github.com/Mottie/tablesorter/wiki">home wiki page</a> <span class="label label-info">more demos</span>!</li>
455 </ul>
456
457 <h4 id="extras">Plugins / Widgets<br>
458 <span class="xsmall"><span class="results">&dagger;</span> these widgets are included in the <code>jquery.tablesorter.widgets.js</code> file (except for extra filter formatter functions).</span>
459 <br>
460 <span class="xsmall"><span class="results">&Dagger;</span> this widget is included with the plugin core.</span>
461 </h4>
462
463 <ul>
464 <li><a href="example-widget-align-character.html">Align Character Widget</a> (<span class="version">v2.15.8</span>; <span class="version updated">v2.19.0</span>).</li>
465 <li><a href="example-widget-build-table.html">Build table Widget</a> (<span class="version">v2.11</span>; <span class="version updated">v2.30.0</span>).</li>
466
467 <li><span class="label label-info">Beta</span> <a href="example-widget-chart.html">Chart Widget</a> (<span class="version">v2.19.0</span>; <span class="version updated">v2.24.0</span>).</li>
468 <li><span class="results">&dagger;</span> <a href="example-widget-columns.html">Columns highlight widget</a> (v2.0.17; <span class="version updated">v2.28.11</span>).</li>
469 <li><a href="example-widget-column-selector.html">Column selector widget</a> (<span class="version">v2.15</span>; <span class="version updated">v2.30.0</span>).</li>
470 <li><a href="example-widget-editable.html">Content editable widget</a> (v2.9; <span class="version updated">v2.31.0</span>).</li>
471 <li><a href="example-widget-current-sort.html">Current Sort Widget</a> (<span class="version">v2.27.0</span>).</li>
472 <li><span class="label label-info">Beta</span> <a href="example-dragtable.html">Dragtable mod</a> - (jQuery UI widget for column reordering [<a class="external" href="http://stackoverflow.com/a/27770224/145346">ref</a>]; <span class="version">v2.24.0</span>).</li>
473 <li><span class="results">&dagger;</span> Filter widget (<span class="version updated">v2.29.4</span>):
474 <ul>
475 <li><a href="example-widget-filter.html">basic</a> (v2.0.18; <span class="version updated">v2.30.0</span>).</li>
476 <li><a href="example-widget-filter-any-match.html">external option (match any column)</a> (<span class="version">v2.13.3</span>; <span class="version updated">v2.27.5</span>).</li>
477 <li><a href="example-widget-filter-external-inputs.html">external inputs</a> (<span class="version">v2.14</span>; <span class="version updated">v2.18.0</span>).</li>
478 <li><a href="example-widget-filter-custom.html">custom filter functions</a> (v2.3.6; <span class="version updated">v2.22.0</span>).</li>
479 <li><a href="example-widget-filter-custom-search.html">custom search types</a> (<span class="version">v2.17.5</span>; <span class="version updated">v2.27.0</span>).</li>
480 <li><a href="example-widget-filter-custom-search2.html">custom search type (example #2: date range)</a> (<span class="version">v2.19.1</span>; <span class="version updated">v2.24.6</span>).</li>
481 <li><a href="example-widget-filter-childrows.html">child rows</a> (<span class="version">v2.23.4</span>).</li>
482 <li>formatter: <a href="example-widget-filter-formatter-1.html">jQuery UI widgets</a> and <a href="example-widget-filter-formatter-2.html">HTML5 Elements</a> (v2.7.7; <span class="version updated">v2.17.5</span>).</li>
483 <li>formatter: <a href="example-widget-filter-formatter-select2.html">select2 v3</a> (<span class="version">v2.16.0</span>; <span class="version updated">v2.29.4</span>).</li>
484 <li>formatter: select2 v4 (TO DO)</li>
485 <li><a href="example-widget-filter-selectmenu.html">Using jQuery UI Selectmenu</a> (<span class="version">v2.24.4</span>; <span class="version updated">v2.28.12</span>).</li>
486 </ul>
487 </li>
488 <li><span class="label label-info">Beta</span> <a href="example-widget-formatter.html">Formatter widget</a> (<span class="version">v2.19.1</span>).</li>
489 <li>Grouping rows widget:
490 <ul>
491 <li><a href="example-widget-grouping.html">basic</a> (v2.8; <span class="version updated">v2.29.0</span>).</li>
492 <li><a href="example-widget-grouping-filter-childrows.html">Grouping + filter + child rows</a> (<span class="updated version">v2.28.0</span>).</li>
493 </ul>
494 </li>
495 <li><a href="example-widget-header-titles.html">Header titles widget</a> (v2.15.6; <span class="version updated">v2.24.4</span>).</li>
496 <li><span class="label label-info">Beta</span> <a href="example-widget-lazyload.html">Lazyload widget</a> (<span class="version">v2.24.0</span>; <span class="version updated">v2.25.7</span>).</li>
497 <li><a href="example-widget-mark.html">Mark widget</a> (<span class="version">v2.27.6</span>).</li>
498 <li><a href="example-widget-math.html">Math widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.31.1</span>).</li>
499 <li>
500 <a href="example-widget-output.html">Output widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.29.0</span>).
501 <br><br>
502 </li>
503
504 <li>Pager plugin (<a href="example-pager.html">basic</a> &amp; <a href="example-pager-ajax.html">ajax</a> demos; <span class="version updated">v2.31.0</span>).</li>
505 <li>
506 Pager widget (<a href="example-widget-pager.html">basic</a> &amp; <a href="example-widget-pager-ajax.html">ajax</a> demos) (<span class="version">v2.12</span>; <span class="version updated">v2.31.0</span>).<br>
507 <br>
508 </li>
509
510 <li><a href="example-widget-print.html">Print widget</a> (<span class="version">v2.16.4</span>; <span class="version updated">v2.25.8</span>).</li>
511 <li><a href="example-widget-reflow.html">Reflow widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.19.0</span>).</li>
512 <li><a href="example-widgets.html">Repeat headers widget</a> (v2.0.5; <span class="version updated">v2.19.0</span>).</li>
513 <li><span class="results">&dagger;</span> <a href="example-widget-resizable.html">Resizable columns widget</a> (v2.0.23.1; <span class="version updated">v2.29.2</span>).</li>
514 <li><span class="results">&dagger;</span> <a href="example-widget-savesort.html">Save sort widget</a> (v2.0.27; <span class="version updated">v2.30.1</span>).</li>
515 <li><a href="example-widget-scroller.html">Scroller widget</a> (<span class="version">v2.9</span>; <span class="version updated">v2.29.2</span>).</li>
516 <li><span class="label label-info">Beta</span> <a href="example-widget-sort-to-hash.html">Sort-to-hash widget</a> (<span class="version">v2.22.4</span>; <span class="version updated">v2.29.0</span>).</li>
517 <li><span class="label label-info">Beta</span> <a href="example-widget-sort-tbodies.html">Sort tbodies widget</a> (<span class="version">v2.22.2</span>; <span class="version updated">v2.28.0</span>).</li>
518 <li><a href="example-widget-static-row.html">Static row widget</a> (<span class="version">v2.16</span>; <span class="version updated">v2.24.0</span>).</li>
519
520 <li><span class="results">&dagger;</span> <a href="example-widget-sticky-header.html">Sticky header widget</a> (v2.0.21.1; <span class="version updated">v2.29.0</span>).</li>
521 <li><a href="example-widget-css-sticky-header.html">Sticky header (css3) widget</a> (<span class="version">v2.14.2</span>; <span class="version updated">v2.30.6</span>).</li>
522
523 <li><span class="results">&dagger;</span> <a href="#function-storage">Storage Widget</a> (<span class="version">v2.20.0</span>; <span class="version updated">v2.30.0</span>).</li>
524
525 <li><span class="label label-info">Beta</span> <a href="example-widget-toggle-tablesorter.html">Toggle Sort & Filter Widget</a> (<span class="version">v2.24.4</span>).</li>
526
527 <li><span class="results">&dagger;</span> UITheme widget (<span class="version">v2.0.9</span>; <span class="version updated">v2.30.0</span>):
528 <ul>
529 <li><a href="example-widget-ui-theme.html">jQuery UI theme</a> (v2.0.9; <span class="version updated">v2.27.0</span>).</li>
530 <li><a href="example-option-theme-bootstrap-v2.html">Bootstrap v2.x</a> (demo added <span class="version">v2.22.0</span>).</li>
531 <li><a href="example-option-theme-bootstrap-v3.html">Bootstrap v3.x</a> (v2.4.0; <span class="version updated">v2.28.4</span>).</li>
532 <li><a href="example-option-theme-bootstrap-v4.html">Bootstrap v4.x</a> (<span class="version updated">v2.29.3</span>) <span class="label warning">NOTE</span> <strong>does not</strong> require the uitheme widget!</li>
533 </ul>
534 </li>
535 <li><span class="label label-info">Beta</span> <a href="example-widget-vertical-group.html">Vertical Group Widget</a> (<span class="version">v2.29.2</span>).</li>
536 <li><span class="label label-info">Beta</span> <a href="example-widget-view.html">View Widget</a> (<span class="version">v2.24.0</span>; <span class="version updated">v2.26.6</span>).</li>
537 <li><span class="results">&Dagger;</span> <a href="example-widget-zebra.html">Zebra stripe widget</a>.</li>
538 </ul>
539
540 <h4 id="custom-parsers">Custom Parsers</h4>
541 <ul>
542 <li><a href="example-parsers-duration.html">Countdown parser</a> (<span class="version">v2.19.0</span>).</li>
543 <li><a href="example-parsers-dates.html">Date parsers</a> (<span class="version">v2.8</span>; <span class="version updated">v2.28.11</span>; includes weekday, month, two-digit year &amp; <a class="external" href="https://sugarjs.com/docs/#/DateParsing">sugar.js</a> date parsers; a <a class="external" href="http://www.datejs.com/">datejs</a> parser is also available).</li>
544 <li><a href="example-parsers-date-range.html">Date range parsers</a> (<span class="version">v2.21.0</span>; <span class="version updated">v2.25.0</span>); if filters, include the <a href="example-widget-filter-custom-search2.html">insideRange</a> filter search type.</li>
545 <li><a href="example-parsers-duration.html">Duration parser</a> (<span class="version">v2.17.8</span>).</li>
546 <li><a href="example-parsers-feet-inch-fraction.html">Feet-inch-fraction parser</a> (<span class="version">v2.8</span>).</li>
547 <li><a href="example-parsers-file-type.html">File type &amp extension parsers</a> (<span class="version">v2.13</span>; <span class="version updated">v2.24.4</span>).</li>
548 <li><a href="example-parsers-named-numbers.html">Huge Numbers parser</a> (<span class="version">v2.25.5</span>).</li>
549 <li><a href="example-parsers-ignore-articles.html">Ignore leading articles parser</a> (Ignore &quot;A&quot;, &quot;An&quot; and &quot;The&quot; in titles) (<span class="version">v2.8</span>).</li>
550 <li><a href="example-widget-grouping.html">Input/select parsers</a> (used by Grouping rows widget) (<span class="version">v2.8</span>; <span class="version updated">v2.30.7</span>).</li>
551 <li><a href="example-parsers-globalize.html">jQuery Globalize</a> (number &amp; date parsers; <span class="version">v2.22.0</span>; <span class="version updated">v2.25.0</span>).</li>
552 <li><a href="example-parsers-leading-zeros.html">Leading zeros parser</a> (<span class="version">v2.28.6</span>).</li>
553 <li><a href="example-parsers-metric.html">Metric parser</a> (<span class="version">v2.8</span>).</li>
554 <li><a href="example-parsers-named-numbers.html">Named Numbers parser</a> (<span class="version">v2.18.0</span>; <span class="version updated">v2.22.0</span>).</li>
555 <li><a href="example-parsers-ip-address.html">Network (IPv4, IPv6 and MAC address parser</a> (<span class="version">v2.12</span>; <span class="version updated">v2.29.3</span>; <span class="label warning">NOTE</span> "ipAddress" parser moved to this file in v2.18.0).</li>
556 <li><a href="example-parsers-roman.html">Roman Numeral parser</a> (<span class="version">v2.17.3</span>).</li>
557 <li><a href="example-option-textsorter-semver.html">Semantic Versioning (Semver) sorting</a> (<span class="version">v2.14.3</span>; <span class="version updated">v2.21.4</span>).</li>
558 </ul>
559
560 <h4>Work-in-progress</h4>
561 <ul>
562 <li><span class="label label-info">Beta</span> <a href="../beta-testing/example-pager-custom-controls.html">Custom pager control script</a> (<span class="version updated">v2.27.8</span>).</li>
563 <li><span class="label label-info">Alpha</span> <a href="../beta-testing/example-widget-column-reorder.html">Column reorder widget</a> - not working 100% with sticky headers.</li>
564 <li><span class="label label-info">Alpha</span> Column reorder using the <a class="external" href="http://stackoverflow.com/a/27770224/145346">dragtable widget</a> (non-mod version).</li>
565 </ul>
566
567 </div>
568 <br class="clear">
569
570 <a id="Configuration"></a>
571 <h1>Configuration</h1>
572
573 <div class="tip">
574 <p></p>
575 tablesorter has many options you can pass in at initialization to achieve different effects<br>
576 <span class="label label-info">TIP!</span> 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.
577 </div>
578
579 <table id="options" class="tablesorter-blue options" data-sortlist="[[0,0]]">
580 <thead>
581 <tr>
582 <th class="property">Property</th>
583 <th class="type">Type</th>
584 <th class="defaults">Default</th>
585 <th class="descrip sorter-false">Description</th>
586 <th class="examples sorter-false">Link</th>
587 </tr>
588 </thead>
589 <tfoot>
590 <tr>
591 <th class="property">Property</th>
592 <th class="type">Type</th>
593 <th class="defaults">Default</th>
594 <th class="descrip">Description</th>
595 <th class="examples">Link</th>
596 </tr>
597 </tfoot>
598 <tbody>
599
600 <tr id="cancelselection">
601 <td><span class="permalink">cancelSelection</span></td>
602 <td>Boolean</td>
603 <td>true</td>
604 <td>Indicates if tablesorter should disable selection of text in the table header (TH). Makes header behave more like a button.</td>
605 <td></td>
606 </tr>
607
608 <tr id="duplicatespan">
609 <td><a href="#" class="permalink">duplicateSpan</a></td>
610 <td>Boolean</td>
611 <td>true</td>
612 <td>Any <code>colspan</code> cells in the tbody may have its content duplicated in the cache for each spanned column (<span class="version">v2.25.0</span>; <span class="version updated">v2.25.8</span>).
613 <div class="collapsible">
614 <p>If <code>true</code>, the cache will contain duplicated cell contents for every column the <code>colspan</code> includes. This makes it easier to sort &amp; filter columns because a cell spanning all columns will only work with one parser.</p>
615 <p>In <span class="version updated">v2.25.8</span>, the contents of cells that are spanned will be set to an empty string only if the <code>textExtraction</code> setting is left as a string. If a function is added, it will be used to attempt to extract other content from the spanned cell (see <a href="http://jsfiddle.net/Mottie/aoLgu7f9/18/">demo</a> for an example).</p>
616 <pre class="prettyprint lang-js">// this row: &lt;tr&gt;&lt;td colspan="3"&gt;foo&lt;/td&gt;&lt;td&gt;bar&lt;/td&gt;&lt;/tr&gt; results in this row cache:
617 [ 'foo', 'foo', 'foo', 'bar' ] // if duplicateSpan = true
618 [ 'foo', '', '', 'bar' ] // if duplicateSpan = false (no textExtraction function)</pre>
619 <span class="label warning">*NOTE*</span>
620 <ul>
621 <li>Cells in the tbody with a <code>rowspan</code> are <em>not yet supported</em> and will not sort or filter as you would expect.</li>
622 <li>Having these values in the cache does not automatically guarantee that all widgets will work as expected with <code>colspan</code>s in the tbody (e.g. scroller widget with fixed columns)</li>
623 </ul>
624 </div>
625 </td>
626 <td><a href="example-colspan.html">Example</a></td>
627 </tr>
628
629 <tr id="cssasc">
630 <td><a href="#" class="permalink">cssAsc</a></td>
631 <td>String</td>
632 <td>&quot;&quot;</td>
633 <td>Additional CSS class applied to style the header with a ascending sort (<span class="version updated">v2.11</span>).
634 <div class="collapsible"><br>
635 Changed to empty string (<code>&quot;&quot;</code>) in v2.11, as the <code>&quot;tablesorter-headerAsc&quot;</code> class will always be added to a header cell with an ascending sort; this option now contains any additional class names to add.
636
637 <p>Example from the blue theme:</p>
638 <pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-headerAsc {
639 background-color: #9fbfdf;
640 background-image: url(black-asc.gif);
641 }</pre>
642 Default changed v2.5 to <code>&quot;tablesorter-headerAsc&quot;</code>. Default changed v2.1.7 to <code>&quot;tablesorter-headerSortUp&quot;</code>. Original default: <code>&quot;headerSortUp&quot;</code></div>
643 </td>
644 <td></td>
645 </tr>
646
647 <tr id="csschildrow">
648 <td><a class="toggle" href="#">cssChildRow</a></td>
649 <td>String</td>
650 <td>&quot;tablesorter-childRow&quot;</td>
651 <td>Add this css class to a child row that should always be attached to its parent. Click on the &quot;cssChildRow&quot; link to toggle the view on the attached child row. Previous default was <code>&quot;expand-child&quot;</code> (Modified v2.4).</td>
652 <td>
653 <a href="example-child-rows.html">1</a>
654 <a href="example-child-rows-filtered.html">2</a>
655 </td>
656 </tr>
657 <tr class="tablesorter-childRow">
658 <td></td>
659 <td></td>
660 <td></td>
661 <td>This is an entirely new row, but attached to the row above while sorting<br>
662 cssChildRow Example HTML:
663 <pre class="prettyprint lang-html">&lt;table width=&quot;100%&quot; border=&quot;1&quot;&gt;
664 &lt;thead&gt;
665 &lt;tr&gt;
666 &lt;th&gt;Item #&lt;/th&gt;
667 &lt;th&gt;Name&lt;/th&gt;
668 &lt;th&gt;Available&lt;/th&gt;
669 &lt;/tr&gt;
670 &lt;/thead&gt;
671 &lt;tbody&gt;
672 &lt;tr&gt;
673 &lt;td&gt;12345&lt;/td&gt;
674 &lt;td&gt;Toy Car&lt;/td&gt;
675 &lt;td&gt;5&lt;/td&gt;
676 &lt;/tr&gt;
677 &lt;tr class=&quot;tablesorter-childRow&quot;&gt; &lt;!-- this row will remain attached to the above row, and not sort separately --&gt;
678 &lt;td colspan=&quot;3&quot;&gt;
679 It&#39;s a toy car!
680 &lt;/td&gt;
681 &lt;/tr&gt;
682 &lt;tr&gt;
683 &lt;td&gt;23456&lt;/td&gt;
684 &lt;td&gt;Toy Plane&lt;/td&gt;
685 &lt;td&gt;2&lt;/td&gt;
686 &lt;/tr&gt;
687 &lt;tr class=&quot;tablesorter-childRow&quot;&gt; &lt;!-- this row will remain attached to the above row, and not sort separately --&gt;
688 &lt;td colspan=&quot;3&quot;&gt;
689 It&#39;s a toy plane!
690 &lt;/td&gt;
691 &lt;/tr&gt;
692 &lt;tr class=&quot;tablesorter-childRow&quot;&gt; &lt;!-- this row will remain attached to the above two rows, and not sort separately --&gt;
693 &lt;td colspan=&quot;3&quot;&gt;
694 and it flies!
695 &lt;/td&gt;
696 &lt;/tr&gt;
697 &lt;/tbody&gt;
698 &lt;/table&gt;</pre>
699 </td>
700 <td></td>
701 </tr>
702
703 <tr id="cssdesc">
704 <td><a href="#" class="permalink">cssDesc</a></td>
705 <td>String</td>
706 <td>&quot;&quot;</td>
707 <td>Additional CSS class applied to style the header with a descending sort (<span class="version updated">v2.11</span>).
708 <div class="collapsible"><br>
709 Changed to empty string in v2.11, as the <code>&quot;tablesorter-headerDesc&quot;</code> class will always be added to a header cell with a descending sort; this option now contains any additional class names to add.
710 <p>Example from the blue theme:</p>
711 <pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-headerDesc {
712 background-color: #8cb3d9;
713 background-image: url(black-desc.gif);
714 }</pre>
715 Default changed v2.5 to <code>&quot;tablesorter-headerDesc&quot;</code>. Default changed v2.1.7 to <code>&quot;tablesorter-headerSortDown&quot;</code>. Original default: <code>&quot;headerSortDown&quot;</code></div>
716 </td>
717 <td></td>
718 </tr>
719
720 <tr id="cssheader">
721 <td><a href="#" class="permalink">cssHeader</a></td>
722 <td>String</td>
723 <td>&quot;&quot;</td>
724 <td>Additional CSS class applied to style the headers (<span class="version updated">v2.11</span>).
725 <div class="collapsible"><br>
726 Changed to empty string in v2.11, as the <code>&quot;tablesorter-header&quot;</code> class will always be added to the table headers; this option now contains any additional class names to add.
727 <p>Example from the blue theme:</p>
728 <pre class="prettyprint lang-css">.tablesorter-blue .tablesorter-header {
729 background-color: #99bfe6;
730 background-repeat: no-repeat;
731 background-position: center right;
732 padding: 4px 20px 4px 4px;
733 white-space: normal;
734 cursor: pointer;
735 }</pre>
736 Default changed v2.1.7 to <code>&quot;tablesorter-header&quot;</code>. Original default: <code>&quot;header&quot;</code></div>
737 </td>
738 <td></td>
739 </tr>
740
741 <tr id="cssheaderrow">
742 <td><a href="#" class="permalink">cssHeaderRow</a></td>
743 <td>String</td>
744 <td>&quot;&quot;</td>
745 <td>Additional CSS class applied to style the header row (<span class="version updated">v2.11</span>).
746 <div class="collapsible"><br>
747 Changed to empty string in v2.11, as the <code>&quot;tablesorter-headerRow&quot;</code> class will always be added to a table header row; this option now contains any additional class names to add.<br>
748 <p>This CSS style was added in v2.4, prior to that the row would get the same class as the header cells. This class was added to make it easier to determine what element was being targeted in the plugin.</p>
749 </div>
750 </td>
751 <td></td>
752 </tr>
753
754 <tr id="cssicon">
755 <td><a href="#" class="permalink">cssIcon</a></td>
756 <td>String</td>
757 <td>&quot;tablesorter-icon&quot;</td>
758 <td>The CSS style used to style the header cell icon (modified v2.7; <span class="version updated">v2.21.1</span>).
759 <div class="collapsible"><br>
760 In <span class="version updated">v2.21.1</span>, adding multiple class names to this option is now properly supported.<br>
761 <br>
762 As of v2.7, the icon will only be added to the header if <strong>both</strong> the <code>cssIcon</code> option is set AND the <a href="#headertemplate"><code>headerTemplate</code></a> option includes the icon tag (<code>{icon}</code>).<br>
763 <br>
764 In v2.4, an <code>&lt;i&gt;</code> element, with this class name, is automatically appended to the header cells. To prevent the plugin from adding an <code>&lt;i&gt;</code> element to the headers, set the <code>cssIcon</code> option to an empty string.<br>
765 </div>
766 </td>
767 <td></td>
768 </tr>
769
770 <tr id="cssiconasc">
771 <td><a href="#" class="permalink">cssIconAsc</a></td>
772 <td>String</td>
773 <td>&quot;&quot;</td>
774 <td>The CSS style added to the header cell icon when the column has an ascending sort (<span class="version">v2.18.3</span>).
775 <div class="collapsible"><br>
776 This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
777 </div>
778 </td>
779 <td></td>
780 </tr>
781
782 <tr id="cssicondesc">
783 <td><a href="#" class="permalink">cssIconDesc</a></td>
784 <td>String</td>
785 <td>&quot;&quot;</td>
786 <td>The CSS style used to style the header cell icon when the column has a descending sort (<span class="version">v2.18.3</span>)
787 <div class="collapsible"><br>
788 This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
789 </div>
790 </td>
791 <td></td>
792 </tr>
793
794 <tr id="cssiconnone">
795 <td><a href="#" class="permalink">cssIconNone</a></td>
796 <td>String</td>
797 <td>&quot;&quot;</td>
798 <td>The CSS style used to style the header cell icon when the column does not have a sort applied (<span class="version">v2.18.3</span>)
799 <div class="collapsible"><br>
800 This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
801 </div>
802 </td>
803 <td></td>
804 </tr>
805
806 <tr id="cssicondisabled">
807 <td><a href="#" class="permalink">cssIconDisabled</a></td>
808 <td>String</td>
809 <td>&quot;&quot;</td>
810 <td>The CSS style used to style the header cell icon when the column sort is disabled (<span class="version">v2.28.13</span>)
811 <div class="collapsible"><br>
812 This class is only applied when the <a href="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <a href="#cssicon"><code>cssIcon</code></a> option.
813 </div>
814 </td>
815 <td></td>
816 </tr>
817
818 <tr id="cssnone">
819 <td><a href="#" class="permalink">cssNone</a></td>
820 <td>String</td>
821 <td>&quot;&quot;</td>
822 <td>Additional CSS class applied to style the header when no sort is applied (<span class="version">v2.15</span>).
823 <div class="collapsible"><br>
824 A <code>&quot;tablesorter-headerUnSorted&quot;</code> class will always be added to an unsorted header cell; this option contains any additional class names to add. Currently, no themes use this class name.
825 </div>
826 </td>
827 <td></td>
828 </tr>
829
830 <tr id="cssprocessing">
831 <td><a href="#" class="permalink">cssProcessing</a></td>
832 <td>String</td>
833 <td>&quot;&quot;</td>
834 <td>Additional CSS class applied to style the header cell while it is being sorted or filtered (v2.4; <span class="version updated">v2.11</span>).
835 <div class="collapsible"><br>
836 Changed to empty string in v2.11, as the <code>&quot;tablesorter-processing&quot;</code> class will always be added to a table cells during processing; this option now contains any additional class names to add.<br>
837 <p>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>.</p>
838 </div>
839 </td>
840 <td></td>
841 </tr>
842
843 <tr id="cssinfoblock">
844 <td><a href="#" class="permalink">cssInfoBlock</a></td>
845 <td>String</td>
846 <td>&quot;tablesorter-infoOnly&quot;</td>
847 <td>All tbodies with this class name will not have its contents sorted. (v2.2).
848 <div class="collapsible">
849 <br>
850 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.
851 <pre class="prettyprint lang-html">&lt;tbody class=&quot;tablesorter-infoOnly&quot;&gt;
852 &lt;tr&gt;
853 &lt;th&gt;The contents of this tbody&lt;/th&gt;
854 &lt;/tr&gt;
855 &lt;tr&gt;
856 &lt;td&gt;will not be sorted&lt;/td&gt;
857 &lt;/tr&gt;
858 &lt;/tbody&gt;</pre>
859 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.
860 <br>
861 <p class="tip">
862 <span class="label label-info">NOTE!</span> 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.
863 </p>
864 </div>
865 </td>
866 <td></td>
867 </tr>
868
869 <tr id="cssnosort">
870 <td><span class="permalink">cssNoSort</span></td>
871 <td>String</td>
872 <td>&quot;tablesorter-noSort&quot;</td>
873 <td>Class name added to element inside header. Clicking on that element, or any elements within it won't cause a sort. (<span class="version">v2.20.0</span>).</td>
874 <td></td>
875 </tr>
876
877 <tr id="cssignorerow">
878 <td><a href="#" class="permalink">cssIgnoreRow</a></td>
879 <td>String</td>
880 <td>&quot;tablesorter-ignoreRow&quot;</td>
881 <td>Class name to add to a table header row if you want all cells within this row to be ignored (<span class="version">v2.18.4</span>).
882 <div class="collapsible">
883 <br>
884 Header rows with this class name will not be added into the <a href="#variable-headers"><code>table.config.$headers</code></a> variable. Meaning, any cells in the row will have sorting disabled, and any form element interaction within these cells will also be ignored by tablesorter.<br>
885 <br>
886 This class name should be added to header rows that contain custom HTML, like for the pager controls, custom filter row or table toolbar.
887 </div>
888 </td>
889 <td><a href="example-colspan.html">1</a> <a href="example-pager-ajax.html#html">2</a></td>
890 </tr>
891
892 <tr id="dateformat">
893 <td><a href="#" class="permalink">dateFormat</a></td>
894 <td>String</td>
895 <td>&quot;mmddyyyy&quot;</td>
896 <td>Set the date format. Here are the available options. (Modified v2.0.23).
897 <div class="collapsible">
898 <ul>
899 <li><code>&quot;mmddyyyy&quot;</code> (default)</li>
900 <li><code>&quot;ddmmyyyy&quot;</code></li>
901 <li><code>&quot;yyyymmdd&quot;</code></li>
902 </ul>
903 In previous versions, this option was set as &quot;us&quot;, &quot;uk&quot; or &quot;dd/mm/yy&quot;. This option was modified to better fit needed date formats. It will only work with four digit years!<br>
904 <br>
905 The sorter should be set to &quot;shortDate&quot; and the date format can be set in the &quot;dateFormat&quot; option or set for a specific columns within the &quot;headers&quot; option.
906 See <a href="example-option-date-format.html">the demo page</a> to see it working.
907 <pre class="prettyprint lang-js">$(function() {
908 $("table").tablesorter({
909
910 dateFormat : "mmddyyyy", // default date format
911
912 // or to change the format for specific columns,
913 // add the dateFormat to the headers option:
914 headers: {
915 0: { sorter: "shortDate" }, // "shortDate" with the default dateFormat above
916 1: { sorter: "shortDate", dateFormat: "ddmmyyyy" }, // day first format
917 2: { sorter: "shortDate", dateFormat: "yyyymmdd" } // year first format
918 }
919
920 });
921 });</pre>
922 Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (Modified v2.3.1):
923 <ul>
924 <li>jQuery data <code>data-dateFormat=&quot;mmddyyyy&quot;</code>.</li>
925 <li>metadata <code>class=&quot;{ dateFormat: 'mmddyyyy'}&quot;</code>. This requires the metadata plugin.</li>
926 <li>headers option <code>headers : { 0 : { dateFormat : 'mmddyyyy' } }</code>.</li>
927 <li>header class name <code>class=&quot;dateFormat-mmddyyyy&quot;</code>.</li>
928 <li>Overall <code>dateFormat</code> option.</li>
929 </ul>
930 </div>
931 </td>
932 <td><a href="example-option-date-format.html">Example</a></td>
933 </tr>
934
935 <tr id="debug">
936 <td><a href="#" class="permalink">debug</a></td>
937 <td>Boolean or String</td>
938 <td>false</td>
939 <td>
940 Set this option to provide useful for development debugging information in the console <span class="version updated">v2.30.0</span>.
941 <div class="collapsible">
942 <p>In <span class="version updated">v2.30.0</span>, set this option as a string containing either "core" and/or a specific widget name; or, a boolean value.</p>
943 <p>When a boolean flag is set, <em>all</em> debugging information is shown in the console.</p>
944 To display debugging information specific to a widget, or widgets include the widget name:
945 <pre class="prettyprint lang-js">$(function() {
946 $("table").tablesorter({
947 // Show debugging info only for the filter and columnSelector widgets
948 // include "core" to only show the core debugging info
949 debug : "filter columnSelector"
950 });
951 });</pre>
952 The option only tests if the string contains the widget name, so <code>"corefilter"</code> would show debugging for both the core and filter widget.
953 </div>
954 </td>
955 <td><a href="example-option-debug.html">Example</a></td>
956 </tr>
957
958 <tr id="delayinit">
959 <td><span class="permalink">delayInit</span></td>
960 <td>Boolean</td>
961 <td>false</td>
962 <td>
963 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.
964 </td>
965 <td><a href="example-option-delay-init.html">Example</a></td>
966 </tr>
967
968 <tr id="emptyto">
969 <td><a href="#" class="permalink">emptyTo</a></td>
970 <td>String</td>
971 <td>&quot;bottom&quot;</td>
972 <td>
973 Option indicating how tablesorter should deal with empty table cells. (Modified v2.1.16, <span class="version updated">v2.16.2</span>).
974 <div class="collapsible">
975 <ul>
976 <li><code>bottom</code> - sort empty table cells to the bottom.</li>
977 <li><code>top</code> - sort empty table cells to the top.</li>
978 <li><code>none</code> or <code>zero</code> - sort empty table cells as if the cell has the value equal to zero.</li>
979 <li><code>emptyMax</code> - sort empty table cells as having a value greater than the <em>max</em> (more positive) value (<span class="version">v2.16.2</span>).</li>
980 <li><code>emptyMin</code> - sort empty table cells as having a value greater than the <em>min</em> (more negative) value (<span class="version">v2.16.2</span>).</li>
981 </ul>
982 Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
983 <ul>
984 <li>jQuery data <code>data-empty=&quot;top&quot;</code>.</li>
985 <li>metadata <code>class=&quot;{ empty: 'top'}&quot;</code>. This requires the metadata plugin.</li>
986 <li>headers option <code>headers : { 0 : { empty : 'top' } }</code>.</li>
987 <li>header class name <code>class=&quot;empty-top&quot;</code>.</li>
988 <li>Overall <code>emptyTo</code> option.</li>
989 </ul>
990 <code>emptyToBottom</code> option was added in v2.1.11, then replaced by the <code>emptyTo</code> option in v2.1.16.
991 </div>
992 </td>
993 <td><a href="example-option-sort-empty.html">Example</a></td>
994 </tr>
995
996 <tr id="headers">
997 <td><a href="#" class="permalink">headers</a></td>
998 <td>Object</td>
999 <td>null</td>
1000 <td>
1001 An object of instructions for per-"header cell" controls in the format: <code>headers: { 0: { option: setting }, ... }</code>
1002 (<span class="version updated">v2.17.1</span>)
1003 <div class="collapsible">
1004 <p>
1005 <span class="label label-warning">Warning</span> <strong>Do not</strong> use this option if your header contains multiple rows or any <code>colspan</code> or <code>rowspan</code>. Instead add a data-attribute or class name to the header (see the first demo for an example).</p>
1006 For example, to disable sorting on the first two columns of a table: <code>headers: { 0: { sorter: false}, 1: {sorter: false} }</code>.<br>
1007 <br>
1008 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).
1009 See the full list of <a href="#parsers">default parsers here</a> or <a href="example-option-built-in-parsers.html">here</a>, or <a href="example-parsers.html">write your own</a>.
1010 <pre class="prettyprint lang-js">$(function() {
1011 $("table").tablesorter({
1012 headers: {
1013
1014 // See example - Disable first header cell; parser false skips extracting content
1015 0: { sorter: false, parser: false },
1016
1017 // WARNING! The "ipAddress" parser was MOVED into the "parser-network.js" file
1018 // in v2.18.0
1019 1: { sorter: "ipAddress" },
1020
1021 // See example 2: Sort column numerically &amp; treat any text as if its value is:
1022 2: { sorter: "digit", empty: "top" }, // zero; sort empty cells to the top
1023 3: { sorter: "digit", string: "max" }, // maximum positive value
1024 4: { sorter: "digit", string: "min" }, // maximum negative value
1025
1026 // Sort the sixth column by date &amp; set the format
1027 5: { sorter: "shortDate", dateFormat: "yyyymmdd" }, // year first format
1028
1029 // See example 3: lock the sort order
1030 // this option will not work if added as metadata
1031 6: { lockedOrder: "asc" },
1032
1033 // See Example 4: Initial sort order direction of 8th header cell
1034 7: { sortInitialOrder: "desc" },
1035
1036 // Set filter widget options for this column
1037 // See the "Applying the filter widget" demo
1038 8: { filter: false }, // disable filter widget for this column
1039 9: { filter: "parsed" }, // use parsed data for this column in the filter search
1040
1041 // Set resizable widget options for this column
1042 10: { resizable: false } // prevent resizing of the 11th column
1043
1044 }
1045 });
1046 });</pre>
1047 Please note that the headers index values corresponds to the table header cells index (zero-based) and <strong>not</strong> the actual columns. For example, given the following table <code>thead</code> markup, the <code>header-index</code> counts the header <code>th</code> cells and does not actually match the <code>data-column</code> index when extra rows and/or <code>colspan</code> or <code>rowspan</code> are included in any of the header cells:
1048 <pre class="prettyprint lang-html">&lt;thead&gt;
1049 &lt;tr&gt;
1050 &lt;th colspan=&quot;4&quot; data-column=&quot;0&quot;&gt;header-index 0&lt;/th&gt;
1051 &lt;/tr&gt;
1052 &lt;tr&gt;
1053 &lt;th data-column=&quot;0&quot;&gt;header-index 1&lt;/th&gt;
1054 &lt;th data-column=&quot;1&quot;&gt;header-index 2&lt;/th&gt;
1055 &lt;th data-column=&quot;2&quot;&gt;header-index 3&lt;/th&gt;
1056 &lt;th data-column=&quot;3&quot;&gt;header-index 4&lt;/th&gt;
1057 &lt;/tr&gt;
1058 &lt;tr&gt;
1059 &lt;th colspan=&quot;2&quot; data-column=&quot;0&quot;&gt;header-index 5&lt;/th&gt;
1060 &lt;th colspan=&quot;2&quot; data-column=&quot;2&quot;&gt;header-index 6&lt;/th&gt;
1061 &lt;/tr&gt;
1062 &lt;/thead&gt;</pre>
1063 So, in the above example, to disable the sort of the second table column (<code>data-column</code> index of 1), the header cell of index 2 needs to be set as follows: <code>2 : { sorter : false }</code>.<br>
1064 <br>
1065 In <span class="version updated">v2.17.0</span>, you can reference the column(s) using a class name, id or column index.
1066 <pre class="prettyprint lang-js">headers : {
1067 '.first-name' : { sorter: 'text' },
1068 '.disabled' : { sorter: false }
1069 }</pre>
1070 <span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>&quot;th:eq()&quot;</code>, <code>&quot;:gt()&quot;</code>, <code>&quot;:lt()&quot;</code>, <code>&quot;:first&quot;</code>, <code>&quot;:last&quot;</code>, <code>&quot;:even&quot;</code> or <code>&quot;:odd&quot;</code>, <code>&quot;:first-child&quot;</code>, <code>&quot;:last-child&quot;</code>, <code>&quot;:nth-child()&quot;</code>, <code>&quot;:nth-last-child()&quot;</code>, etc.
1071 </div>
1072 </td>
1073 <td>
1074 <a href="example-options-headers.html">1</a>
1075 <a href="example-options-headers-digits-strings.html">2</a>
1076 <a href="example-options-headers-locked.html">3</a>
1077 <a href="example-options-headers-order.html">4</a>
1078 <a href="example-options-headers-parser.html">5</a>
1079 </td>
1080 </tr>
1081
1082 <tr id="headertemplate">
1083 <td><a href="#" class="permalink">headerTemplate</a></td>
1084 <td>String</td>
1085 <td>&quot;{content}&quot;</td>
1086 <td>This is a template string which allows adding additional content to the header while it is being built (v2.7; <span class="version updated">v2.17.8</span>).
1087 <div class="collapsible"><br>
1088 In <span class="version updated">v2.17.8</span>, if this option is set to an empty string (<code>''</code>), an inner div will no longer be wrapped around the header content.<br>
1089 <br>
1090 This template string has two modifying tags: <code>{content}</code> and <code>{icon}</code>.<br>
1091 <code>{content}</code> will be replaced by the current header HTML content.<br>
1092 <code>{icon}</code> will be replaced by <code>&lt;i class=&quot;tablesorter-icon&quot;&gt;&lt;/i&gt;</code>, but only if a class name is defined in the <code>cssIcon</code> option.<br>
1093 <br>
1094 This template string may also contain HTML, e.g (<code>'&lt;em&gt;{content}&lt;/em&gt; {icon}'</code>)<br>
1095 <br>
1096 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).
1097 </div>
1098 </td>
1099 <td><a href="example-option-render-template.html">Example</a></td>
1100 </tr>
1101
1102 <tr id="ignorecase">
1103 <td><span class="permalink">ignoreCase</span></td>
1104 <td>Boolean</td>
1105 <td>true</td>
1106 <td>When true, text sorting will ignore the character case. If false, upper case characters will sort before lower case. (v2.2).</td>
1107 <td></td>
1108 </tr>
1109
1110 <tr id="initialized">
1111 <td><a href="#" class="permalink">initialized</a></td>
1112 <td>Function</td>
1113 <td>null</td>
1114 <td>This callback fires when tablesorter has completed initialization. (v2.2).
1115 <div class="collapsible">
1116 <pre class="prettyprint lang-js">$(function() {
1117
1118 // bind to tablesorter-initialized event BEFORE initializing tablesorter*
1119 $("table")
1120 .bind("tablesorter-initialized",function(e, table) {
1121 // do something after tablesorter has initialized
1122 });
1123
1124 // initialize the tablesorter plugin
1125 $("table").tablesorter({
1126 // this is equivalent to the above bind method
1127 initialized : function(table) {
1128 // do something after tablesorter has initialized
1129 }
1130 });
1131
1132 });</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
1133 </td>
1134 <td></td>
1135 </tr>
1136
1137 <tr id="initwidgets">
1138 <td><a href="#" class="permalink">initWidgets</a></td>
1139 <td>Boolean</td>
1140 <td>true</td>
1141 <td>Apply widgets after table initializes (v2.3.5).
1142 <div class="collapsible">
1143 When true, all widgets set by the <code>widgets</code> option will apply after tablesorter has initialized, this is the normal behavior.<br>
1144 <br>
1145 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>
1146 <br>
1147 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.
1148 </div>
1149 </td>
1150 <td></td>
1151 </tr>
1152
1153 <tr id="widgetclass">
1154 <td><a href="#" class="permalink">widgetClass</a></td>
1155 <td>String</td>
1156 <td>&quot;widget-{name}&quot;</td>
1157 <td>When the table has a class name that matches the template and a widget id that matches the <code>{name}</code>, the widget will automatically be added to the table (<span class="version">v2.18.0</span>)
1158 <div class="collapsible">
1159 <br>
1160 By default, this option is set to <code>'widget-{name}'</code>. So if the table has a class name of <code>widget-zebra</code> the zebra widget will be automatically added to the <code>config.widgets</code> option and applied to the table.<br>
1161 <br>
1162 Some widget ID's with special characters may not be detected; ID's with letters, numbers, underscores and/or dashes will be correctly detected.<br>
1163 <br>
1164 The template string *must* contain the <code>{name}</code> tag.
1165 </div>
1166 </td>
1167 <td></td>
1168 </tr>
1169
1170 <tr id="onrenderheader">
1171 <td><a href="#" class="permalink">onRenderHeader</a></td>
1172 <td>Function</td>
1173 <td>null</td>
1174 <td>
1175 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 (<span class="version updated">v2.18.0</span>).
1176 <div class="collapsible">
1177 <br>
1178 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 class="external" href="http://www.pengoworks.com/workshop/jquery/tablesorter/tablesorter.htm">source</a>).<br>
1179 <p>Function parameters:</p>
1180 <ul>
1181 <li><code>index</code> - zero-based index of the current table header cell; this value is <em>not</em> indicative of the column index, as it is simply a count of header cells. So it will be effected by rowspan, colspan and multiple rows in the header.</li>
1182 <li><code>config</code> - The current <code>table.config</code>.</li>
1183 <li><code>$table</code> - This value is the current table jQuery object. If this function is being applied to cloned headers, as is does in the stickyHeaders widget, then this value will contain the sticky header clone added after the current table, and not the main table (<span class="version">v2.18.0</span>).</li>
1184 </ul>
1185 <pre class="prettyprint lang-js">$(function() {
1186 $("table").tablesorter({
1187 headerTemplate: '{content}',
1188 onRenderHeader: function (index, config, $table) {
1189 $(this).find('div').addClass('roundedCorners');
1190 }
1191 });
1192 });</pre>and you'll end up with this HTML (only the thead is shown)<pre class="prettyprint lang-html">&lt;thead&gt;
1193 &lt;tr&gt;
1194 &lt;th class=&quot;tablesorter-header&quot;&gt;&lt;div class=&quot;tablesorter-header-inner roundedCorners&quot;&gt;Column 1&lt;/div&gt;&lt;/th&gt;
1195 &lt;th class=&quot;tablesorter-header&quot;&gt;&lt;div class=&quot;tablesorter-header-inner roundedCorners&quot;&gt;Column 2&lt;/div&gt;&lt;/th&gt;
1196 &lt;/tr&gt;
1197 &lt;/thead&gt;</pre>
1198 <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>
1199 </div>
1200 </td>
1201 <td><a href="example-option-render-header.html">Example</a></td>
1202 </tr>
1203
1204 <tr id="onrendertemplate">
1205 <td><a href="#" class="permalink">onRenderTemplate</a></td>
1206 <td>Function</td>
1207 <td>null</td>
1208 <td>
1209 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 (v2.7).
1210 <div class="collapsible">
1211 <br>
1212 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.
1213 <p>Function parameters:</p>
1214 <ul>
1215 <li><code>index</code> - zero-based index of the current table header cell; this value is <em>not</em> indicative of the column index, as it is simply a count of header cells. So it will be effected by rowspan, colspan and multiple rows in the header.</li>
1216 <li><code>template</code> - A rendered <code>headerTemplate</code> HTML string.</li>
1217 </ul>
1218 <pre class="prettyprint lang-js">$(function() {
1219 $("table").tablesorter({
1220 headerTemplate: '{icon}{content}',
1221 onRenderTemplate: function (index, template) {
1222 return '&lt;em&gt;' + (index + 1) + ':&lt;/em&gt; ' + template;
1223 }
1224 });
1225 });</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>
1226 <br>
1227 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">&lt;thead&gt;
1228 &lt;tr&gt;
1229 &lt;th class=&quot;tablesorter-header&quot;&gt;&lt;div class=&quot;tablesorter-header-inner&quot;&gt;&lt;em&gt;1:&lt;/em&gt; &lt;i class=&quot;tablesorter-icon&quot;&gt;&lt;/i&gt;First Name&lt;/div&gt;&lt;/th&gt;
1230 &lt;th class=&quot;tablesorter-header&quot;&gt;&lt;div class=&quot;tablesorter-header-inner&quot;&gt;&lt;em&gt;2:&lt;/em&gt; &lt;i class=&quot;tablesorter-icon&quot;&gt;&lt;/i&gt;Last Name&lt;/div&gt;&lt;/th&gt;
1231 &lt;/tr&gt;
1232 &lt;/thead&gt;</pre>
1233 <small>* Note: If the <code>cssIcon</code> option is an empty string, the <code>{icon}</code> tag will also become an empty string.</small>
1234 </div>
1235 </td>
1236 <td><a href="example-option-render-template.html">Example</a></td>
1237 </tr>
1238
1239 <tr id="selectorheaders">
1240 <td><a href="#" class="permalink">selectorHeaders</a></td>
1241 <td>String</td>
1242 <td>&quot;&gt; thead th, &gt; thead td&quot;</td>
1243 <td>jQuery selectors used to find cells in the header.
1244 <div class="collapsible">
1245 <br>
1246 You can change this, but the table will still need the required thead and tbody before this plugin will work properly.
1247 <br>Added <code>&gt;</code> to the selector in v2.3 to prevent targeting nested table headers. It was modified again in v2.4 to include <code>td</code> cells within the thead.
1248 </div>
1249 </td>
1250 <td></td>
1251 </tr>
1252
1253 <tr id="selectorremove">
1254 <td><a href="#" class="permalink">selectorRemove</a></td>
1255 <td>String</td>
1256 <td>&quot;tr.remove-me&quot;</td>
1257 <td>This CSS class name can be applied to all rows that are to be removed prior to triggering a table update. (v2.1).
1258 <div class="collapsible">
1259 <br>
1260 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.
1261 </div>
1262 </td>
1263 <td></td>
1264 </tr>
1265
1266 <tr id="selectorsort">
1267 <td><span class="permalink">selectorSort</span></td>
1268 <td>String</td>
1269 <td>&quot;th, td&quot;</td>
1270 <td>jQuery selector of content within <a href="#selectorheaders"><code>selectorHeaders</code></a> that is clickable to trigger a sort (v2.4).</td>
1271 <td><a href="example-option-selectorsort.html">Example</a></td>
1272 </tr>
1273
1274 <tr id="resort">
1275 <td><a href="#" class="permalink">resort</a></td>
1276 <td>Boolean</td>
1277 <td>true</td>
1278 <td>When this option is <code>true</code> any applied sort on the table will be reapplied after an update method (<span class="version">v2.19.0</span>).
1279 <div class="collapsible">
1280 <br>
1281 Specifically, this option applies to the <a href="#updateall"><code>updateAll</code></a>, <a href="#update"><code>update</code></a>, <a href="#addrows"><code>addRows</code></a> and <a href="#updatecell"><code>updateCell</code></a> methods and is checked after the method has completed updating the internal cache.<br>
1282 <br>
1283 If <code>false</code>, the widgets will still be refreshed for all but the <code>updateCell</code> method - this behavior was added in v2.19.0.<br>
1284 <br>
1285 <span class="label label-info">Note</span> when triggering one of the above methods, and passing a defined <code>resort</code> parameter, it will override this setting.<br>
1286 <span class="label label-warning">Note</span> if a sort is not reapplied, problems with some widgets may occur, namely with the grouping widget.
1287 </div>
1288 </td>
1289 <td></td>
1290 </tr>
1291
1292 <tr id="serversidesorting">
1293 <td><span class="permalink">serverSideSorting</span></td>
1294 <td>Boolean</td>
1295 <td>false</td>
1296 <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>
1297 <td></td>
1298 </tr>
1299
1300 <tr id="showprocessing">
1301 <td><span class="permalink">showProcessing</span></td>
1302 <td>Boolean</td>
1303 <td>false</td>
1304 <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>
1305 <td><a href="example-option-show-processing.html">Example</a></td>
1306 </tr>
1307
1308 <tr id="sortforce">
1309 <td><a href="#" class="permalink">sortForce</a></td>
1310 <td>Array</td>
1311 <td>null</td>
1312 <td>Use to add an additional forced sort that is <strong>prepended</strong> to <a href="#sortlist"><code>sortList</code></a>.
1313 <div class="collapsible">
1314 <p>
1315 <span class="label label-warning">NOTE</span> Only when the user interacts with the table will the <code>sortForce</code> and <code>sortAppend</code> settings be applied. During initialization, and while setting the <code>sortList</code> through the API, both the <code>sortForce</code> and <code>sortAppend</code> settings are ignored. This will allow you to have explicit control over the sorting.
1316 </p>
1317 For example, <code>sortForce: [[0,0]]</code> will sort the first column in ascending order. After the forced sort, the user selected column(s), <em>but not during initialzation</em>, 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>
1318 <br>
1319 There are three options to determine the sort order and this is the order of priority:
1320 <ol>
1321 <li><a href="#sortforce"><code>sortForce</code></a> forces the user to have this/these column(s) sorted first (null by default).</li>
1322 <li><a href="#sortlist"><code>SortList</code></a> is the initial sort order of the columns.</li>
1323 <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; <span class="version updated">v2.24.0</span>).</li>
1324 </ol>
1325 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>.
1326 <pre class="prettyprint lang-js">$(function() {
1327 $("table").tablesorter({
1328 sortForce : [[0,0]], // Always sort first column first
1329 sortList : [[1,0], [2,0]], // initial sort columns (2nd and 3rd)
1330 sortAppend : [[3,0]] // Always add this sort on the end (4th column)
1331 });
1332 });</pre></div>
1333 </td>
1334 <td><a href="example-option-sort-force.html">Example</a></td>
1335 </tr>
1336
1337 <tr id="sortlist">
1338 <td><a href="#" class="permalink">sortList</a></td>
1339 <td>Array</td>
1340 <td>null</td>
1341 <td>Use to add an initial sort to the table.
1342 <div class="collapsible">
1343 <p>
1344 <span class="label label-warning">NOTE</span> Only when the user interacts with the table will the <code>sortForce</code> and <code>sortAppend</code> settings be applied. During initialization, and while setting the <code>sortList</code> through the API, both the <code>sortForce</code> and <code>sortAppend</code> settings are ignored. This will allow you to have explicit control over the sorting.
1345 </p>
1346 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>
1347 <pre class="prettyprint lang-js">$(function() {
1348 $("table").tablesorter({
1349 sortList : [[1,0], [2,0]] // initial sort columns (2nd and 3rd)
1350 });
1351 });</pre>
1352 This option can also be set using data-attributes (v2.3.1), jQuery data or metadata on the table:
1353 <table class="info">
1354 <tfoot>
1355 <tr><td colspan="2"><strong>** Note</strong>: <code>data-sortlist</code> data is not supported in jQuery versions older than 1.4.</td></tr>
1356 </tfoot>
1357 <tbody>
1358 <tr><th>jQuery data</th><td><code>&lt;table data-sortlist="[[0,0],[4,0]]"&gt;</code> <strong>**</strong></td></tr>
1359 <tr><th>Meta data</th><td><code>&lt;table class="tablesorter {sortlist: [[0,0],[4,0]]}"&gt;</code></td></tr>
1360 </tbody>
1361 </table>
1362 </div>
1363 </td>
1364 <td><a href="example-option-sort-list.html">Example</a></td>
1365 </tr>
1366
1367 <tr id="sortappend">
1368 <td><a href="#" class="permalink">sortAppend</a></td>
1369 <td>Array or Object</td>
1370 <td>null</td>
1371 <td>Use to add an additional forced sort that will be appended to the dynamic selections by the user (<span class="version updated">v2.24.0</span>).
1372 <div class="collapsible">
1373 <p>
1374 <span class="label label-warning">NOTE</span> Only when the user interacts with the table will the <code>sortForce</code> and <code>sortAppend</code> settings be applied. During initialization, and while setting the <code>sortList</code> through the API, both the <code>sortForce</code> and <code>sortAppend</code> settings are ignored. This will allow you to have explicit control over the sorting.
1375 </p>
1376 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>
1377 <pre class="prettyprint lang-js">$(function() {
1378 $("table").tablesorter({
1379 sortAppend : [[1,0], [2,0]] // always append sorting of 2nd and 3rd column
1380 });
1381 });</pre>
1382 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.
1383 <p>In <span class="version updated">v2.24.0</span>, the <code>sortAppend</code> option now accepts an object containing column indexes.</p>
1384 <p>Also, the sort direction can be set using "a" (ascending), "d" (descending), "n" (next), "s" (same) &amp; "o" (opposite):</p>
1385 <pre class="prettyprint lang-js">$(function() {
1386 $("table").tablesorter({
1387 sortAppend: {
1388 0 : [[ 1,'a' ]], // always apply ascending sort
1389 2 : [[ 3,'o' ]], // sort "o"pposite of column 2 direction
1390 4 : [[ 5,'s' ], [ 0,'s' ]] // sort "s"ame as column 4 direction
1391 }
1392 });
1393 });</pre>
1394 </div>
1395 </td>
1396 <td><a href="example-option-sort-append.html">Example</a></td>
1397 </tr>
1398
1399 <tr id="sortinitialorder">
1400 <td><a href="#" class="permalink">sortInitialOrder</a></td>
1401 <td>String</td>
1402 <td>&quot;asc&quot;</td>
1403 <td>
1404 This sets the direction a column will sort when clicking on the header for the first time. Valid arguments are <code>&quot;asc&quot;</code> for Ascending or <code>&quot;desc&quot;</code> for Descending.<br>
1405 <div class="collapsible">
1406 <br>
1407 This order can also be set by desired column using the <a href="#headers"><code>headers</code></a> option (v2.0.8).<br>
1408 <br>
1409 Individual columns can be modified by adding the following (they all do the same thing), set in order of priority (modified v2.3.1):
1410 <ul>
1411 <li>jQuery data <code>data-sortInitialOrder=&quot;asc&quot;</code>.</li>
1412 <li>metadata <code>class=&quot;{ sortInitialOrder: 'asc'}&quot;</code>. This requires the metadata plugin.</li>
1413 <li>headers option <code>headers : { 0 : { sortInitialOrder : 'asc' } }</code>.</li>
1414 <li>header class name <code>class=&quot;sortInitialOrder-asc&quot;</code>.</li>
1415 <li>Overall <code>sortInitialOrder</code> option.</li>
1416 </ul>
1417 </div>
1418 </td>
1419 <td>
1420 <a href="example-option-sort-order.html">1</a>
1421 <a href="example-options-headers-order.html">2</a>
1422 </td>
1423 </tr>
1424
1425 <tr id="sortlocalecompare">
1426 <td><a href="#" class="permalink">sortLocaleCompare</a></td>
1427 <td>Boolean</td>
1428 <td>false</td>
1429 <td>
1430 Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. (Modified v2.2).
1431 <div class="collapsible">
1432 <ul>
1433 <li>This option no longer switches the sort to use the <code>String.localeCompare</code> method.</li>
1434 <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>
1435 <li>If <code>false</code> (default), any accented characters are treated as their value in the standard unicode order.</li>
1436 <li>The following characters are replaced for both upper and lower case (information obtained from <a class="external" href="https://sugarjs.com/docs/#/ArraySorting">sugar.js sorting equivalents</a> table):
1437 <ul>
1438 <li><code>&#x00e1;&#x00e0;&#x00e2;&#x00e3;&#x00e4;</code> replaced with <code>a</code></li>
1439 <li><code>&#x00e7;</code> replaced with <code>c</code></li>
1440 <li><code>&#x00e9;&#x00e8;&#x00ea;&#x00eb;</code> replaced with <code>e</code></li>
1441 <li><code>&#x00ed;&#x00ec;&#x0130;&#x00ee;&#x00ef;</code> replaced with <code>i</code></li>
1442 <li><code>&#x00f3;&#x00f2;&#x00f4;&#x00f5;&#x00f6;&#x014d;</code> replaced with <code>o</code></li>
1443 <li><code>&#x00fa;&#x00f9;&#x00fb;&#x00fc;</code> replaced with <code>u</code></li>
1444 <li><code>&#x00df;</code> replaced with <code>S</code></li>
1445 </ul>
1446 </li>
1447 <li>Please see the example page for instrcutions on how to modify the above equivalency table.</li>
1448 <li>If you would like to continue 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:
1449 <pre class="prettyprint lang-js">$('table').tablesorter({
1450 textSorter: function(a,b) {
1451 return a.localeCompare(b);
1452 }
1453 });</pre></li>
1454 </ul>
1455 <p class="tip">
1456 <span class="label label-info">NOTE!</span> 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>.
1457 </p>
1458 <del>Boolean flag indicating whenever to use javascript <code>String.localeCompare</code> method or not.<br>
1459 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>
1460 </div>
1461 </td>
1462 <td><a href="example-locale-sort.html">Example</a></td>
1463 </tr>
1464
1465 <tr id="sortreset">
1466 <td><a href="#" class="permalink">sortReset</a></td>
1467 <td>Boolean</td>
1468 <td>false</td>
1469 <td>
1470 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).
1471 <div class="collapsible">
1472 <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.
1473 </div>
1474 </td>
1475 <td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
1476 </tr>
1477
1478 <tr id="sortresetkey">
1479 <td><span class="permalink">sortResetKey</span></td>
1480 <td>String</td>
1481 <td>&quot;ctrlKey&quot;</td>
1482 <td>The key used to reset sorting on the entire table. Defaults to the control key. The other options are <code>&quot;shiftKey&quot;</code> or <code>&quot;altKey&quot;</code> (<a class="external" href="https://developer.mozilla.org/en/DOM/MouseEvent">reference</a>).</td>
1483 <td></td>
1484 </tr>
1485
1486 <tr id="sortrestart">
1487 <td><span class="permalink">sortRestart</span></td>
1488 <td>Boolean</td>
1489 <td>false</td>
1490 <td>
1491 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).
1492 </td>
1493 <td><a href="example-option-sortreset-sortrestart.html">Example</a></td>
1494 </tr>
1495
1496 <tr id="sortstable">
1497 <td><a href="#" class="permalink">sortStable</a></td>
1498 <td>Boolean</td>
1499 <td>false</td>
1500 <td>
1501 Setting this option to <code>true</code> and sorting two rows with exactly the same content, the original sort order is maintained (<span class="version">v2.14</span>).
1502 <div class="collapsible"><br>
1503 This isn't exactly a <a class="external" href="http://en.wikipedia.org/wiki/Unstable_sort#Stability">stable sort</a> because the sort order maintains the original unsorted order when sorting the column in an ascending direction. When sorting the column in a descending order, the opposite of the original unsorted order is returned. If that doesn't make any sense, please refer to <a href="https://github.com/Mottie/tablesorter/issues/419">issue #419</a>.
1504 </div>
1505 </td>
1506 <td><a href="example-locale-sort.html">Example</a></td>
1507 </tr>
1508
1509 <tr id="sortmultisortkey">
1510 <td><a href="#" class="permalink">sortMultiSortKey</a></td>
1511 <td>String</td>
1512 <td>&quot;shiftKey&quot;</td>
1513 <td>
1514 The key used to select more than one column for multi-column sorting. Defaults to the <kbd>Shift</kbd> key.
1515 <div class="collapsible">
1516 <p>The other options include <code>&quot;ctrlKey&quot;</code> or <code>&quot;altKey&quot;</code> (<a class="external" href="https://developer.mozilla.org/en/DOM/MouseEvent">reference</a>)</p>
1517 To make a multisort always active, use any of the other event objects that are always <a class="external" href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">"truthy"</a> like <code>"type"</code> or <code>"bubbles"</code>. See <a href="https://github.com/Mottie/tablesorter/issues/1200">issue #1200</a>).
1518 </div>
1519 </td>
1520 <td><a href="example-option-sort-key.html">Example</a></td>
1521 </tr>
1522
1523 <tr id="stringto">
1524 <td><a href="#" class="permalink">stringTo</a></td>
1525 <td>String</td>
1526 <td>&quot;max&quot;</td>
1527 <td>
1528 A key word indicating how tablesorter should deal with text inside of numerically sorted columns. (v2.1.16).
1529 <div class="collapsible"><br>
1530 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:
1531 <ul>
1532 <li><code>&quot;max&quot;</code> will treat any text in that column as a value greater than the <em>max</em> (more positive) value. Renamed from "max+".</li>
1533 <li><code>&quot;min&quot;</code> will treat any text in that column as a value greater than the <em>min</em> (more negative) value. Renamed from "max-".</li>
1534 <li><code>&quot;top&quot;</code> will always sort the text to the top of the column.</li>
1535 <li><code>&quot;bottom&quot;</code> will always sort the text to the bottom of the column.</li>
1536 <li><code>&quot;none&quot;</code> or <code>&quot;zero&quot;</code> will treat the text as if it has a value of zero.</li>
1537 </ul>
1538 Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
1539 <ul>
1540 <li>jQuery data <code>data-string=&quot;top&quot;</code>.</li>
1541 <li>metadata <code>class=&quot;{ string: 'top'}&quot;</code>. This requires the metadata plugin.</li>
1542 <li>headers option <code>headers : { 0 : { string : 'top' } }</code>.</li>
1543 <li>header class name <code>class=&quot;string-top&quot;</code>.</li>
1544 <li>Overall <code>stringTo</code> option.</li>
1545 </ul>
1546 </div>
1547 </td>
1548 <td><a href="example-options-headers-digits-strings.html">Example</a></td>
1549 </tr>
1550
1551 <tr id="tabindex">
1552 <td><span class="permalink">tabIndex</span></td>
1553 <td>Boolean</td>
1554 <td>true</td>
1555 <td>Add a tabindex to the headers for keyboard accessibility; this was previously always applied (<span class="version">v2.14</span>).</td>
1556 <td></td>
1557 </tr>
1558
1559 <tr id="tableClass">
1560 <td><a href="#" class="permalink">tableClass</a></td>
1561 <td>String</td>
1562 <td>&quot;&quot;</td>
1563 <td>Additional CSS class applied to style the table (<span class="version updated">v2.11</span>).
1564 <div class="collapsible"><br>
1565 Changed to empty string in v2.11, as the <code>&quot;tablesorter&quot;</code> class will always be added to the table; this option now contains any additional class names to add.
1566 <p>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.</p>
1567 Modify this option if you are not using the default css, or if you are using a completely custom stylesheet.
1568 </div>
1569 </td>
1570 <td></td>
1571 </tr>
1572
1573 <tr id="theme">
1574 <td><a href="#" class="permalink">theme</a></td>
1575 <td>String</td>
1576 <td>&quot;default&quot;</td>
1577 <td>This option will add a theme css class name to the table <code>&quot;tablesorter-{theme}&quot;</code> for styling (v2.4; <span class="version updated">v2.18.0</span>).
1578 <div class="collapsible">
1579 <br>
1580 <span class="label alert">*NOTE*</span> If creating a custom theme file, make sure to include a filter definition to hide filtered out rows:
1581 <pre class="prettyprint lang-css">.filtered { display: none; }</pre>
1582 <p><span class="label label-info">Note</span> the <code>.filtered</code> class can be modified using the <a href="#widget-filter-filteredrow"><code>filter_filteredRow</code> option</a>.</p>
1583 When changing this theme option (the actual theme name is inside parentheses), make sure that the appropriate css theme file has also been loaded. Default theme files include:
1584 <a href="themes.html" target="_blank" title="open themes in a new window">see all themes</a><br>
1585 <iframe style="width:100%;height:300px;" src="themes.html"></iframe>
1586 <hr>
1587 <h3>uitheme widget</h3>
1588 <p>You will need to use the uitheme widget to extend the theme to apply css from jQuery UI, Bootstrap (v3 &amp; earlier) or other css libraries.</p>
1589 <h4>Modify a theme</h4>
1590 <p>If you want to modify the existing themes ("jui" and "bootstrap"), it can be done as follows:</p>
1591 <p>Modify the class names by extending from the <a href="#variable-themes"><code>$.tablesorter.themes</code></a> variable</p>
1592 <p><span class="label label-info">Note</span> there is no need to extend from the entire list of class names, just include the key:value pairs that are being changed:</p>
1593 <pre class="prettyprint lang-js">// Extend a theme to modify any of the default class names
1594 $.extend($.tablesorter.themes.jui, {
1595 // change default jQuery uitheme icons - find the full list of icons
1596 // here: http://jqueryui.com/themeroller/ (hover over them for their name)
1597 table : 'ui-widget ui-widget-content ui-corner-all', // table classes
1598 caption : 'ui-widget-content',
1599 // header class names
1600 header : 'ui-widget-header ui-corner-all ui-state-default', // header classes
1601 sortNone : '',
1602 sortAsc : '',
1603 sortDesc : '',
1604 active : 'ui-state-active', // applied when column is sorted
1605 hover : 'ui-state-hover', // hover class
1606 // icon class names
1607 icons : 'ui-icon', // icon class added to the &lt;i&gt; in the header
1608 iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // "caret" class renamed in jQuery v1.12.0
1609 iconSortAsc : 'ui-icon-carat-1-n ui-icon-caret-1-n',
1610 iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s',
1611 // other
1612 filterRow : '',
1613 footerRow : '',
1614 footerCells : '',
1615 even : 'ui-widget-content', // even row zebra striping
1616 odd : 'ui-state-default' // odd row zebra striping
1617 });</pre>
1618
1619 <h4>Custom theme</h4>
1620 To add a new uitheme, define it as follows (replace "custom" with the name of your theme):
1621 <pre class="prettyprint lang-js">$.tablesorter.themes.custom = {
1622 table : 'table', // table classes
1623 header : 'header', // header classes
1624 footerRow : '',
1625 footerCells: '',
1626 icons : 'icon', // icon class added to the &lt;i&gt; in the header
1627 sortNone : 'sort-none', // unsorted header
1628 sortAsc : 'sort-asc', // ascending sorted header
1629 sortDesc : 'sort-desc', // descending sorted header
1630 active : 'sort-active', // applied when column is sorted
1631 hover : 'hover', // hover class
1632 filterRow : 'filters', // class added to the filter row
1633 even : 'even', // even row zebra striping
1634 odd : 'odd' // odd row zebra striping
1635 }</pre>
1636 Then use it by adding the name of your theme to the <code>theme</code> option:
1637 <pre class="prettyprint lang-js">$(function() {
1638 $("table").tablesorter({
1639 // set the new theme name from $.tablesorter.themes here
1640 theme : 'custom',
1641 // add {icon} to template (if needed)
1642 headerTemplate: '{content}{icon}',
1643 // make sure to initialize uitheme widget
1644 widgets : ["uitheme"]
1645 });
1646 });</pre>
1647 </div>
1648 </td>
1649 <td><a href="themes.html">Example</a></td>
1650 </tr>
1651
1652 <tr id="textattribute">
1653 <td><a href="#" class="permalink">textAttribute</a></td>
1654 <td>String</td>
1655 <td>&quot;data-text&quot;</td>
1656 <td>This data-attribute can be added to any tbody cell and can contains alternate cell text (<span class="version">v2.16.0</span>).
1657 <div class="collapsible">
1658 <br>
1659 This option contains the name of the data-attribute used by the <a href="#textextraction"><code>textExtraction</code></a> function. Add it to the cell(s) as follows:
1660 <pre class="prettyprint lang-html">&lt;td data-text="1"&gt;First repository&lt;/td&gt;</pre>
1661 <span class="label label-info">Note</span> This option only works when the <a href="#textextraction"><code>textExtraction</code></a> option is set to "basic".
1662 <p><span class="label alert">*NOTE*</span> It is important to know that the filter widget is set to use extracted (parsed) content as a parsed value and the raw cell content as unparsed values; and most of the time the filter widget is searching unparsed content. But, when a data-attribute is used, both the parsed and raw cached data will contain the <em>exact same content</em> (<a href="https://github.com/Mottie/tablesorter/issues/983">ref</a>)!</p>
1663 </div>
1664 </td>
1665 <td></td>
1666 </tr>
1667
1668 <tr id="textextraction">
1669 <td><a href="#" class="permalink">textExtraction</a></td>
1670 <td>Multiple*</td>
1671 <td>&quot;basic&quot;</td>
1672 <td>Defines which method is used to extract data from a table cell for sorting (<span class="version updated">v2.19.0</span>)
1673 <div class="collapsible">
1674 <br>
1675 * <span class="label label-info">Note</span> This option accepts multiple types (String, Object or Function); see below for further details.
1676 <p></p>
1677 In <span class="version updated">v2.19.0</span>, the code was further optimized. When set to <code>&quot;basic&quot;</code> (the default), the textExtraction code will check for data-attributes, otherwise, any other string value setting will skip the data-attribute value check; because of this change, there is a noticable lessening of initialization time in Internet Explorer.
1678 <p></p>
1679 In <span class="version updated">v2.17.0</span>, the <code>textExtraction</code> column can also be referenced by using a jQuery selector (e.g. class name, id or column index) that points to a table <em>header</em> cell.<br>
1680 <pre class="prettyprint lang-js">textExtraction : {
1681 // 'jQuery thead cell selector' : function ( new method )
1682 '.styled' : function(node, table, cellIndex) {
1683 return $(node).find('strong').text();
1684 },
1685 // columnIndex : function ( original method )
1686 2 : function(node, table, cellIndex) {
1687 return $(node).find('img').attr('title');
1688 }
1689 }</pre>
1690 <span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>&quot;th:eq()&quot;</code>, <code>&quot;:gt()&quot;</code>, <code>&quot;:lt()&quot;</code>, <code>&quot;:first&quot;</code>, <code>&quot;:last&quot;</code>, <code>&quot;:even&quot;</code> or <code>&quot;:odd&quot;</code>, <code>&quot;:first-child&quot;</code>, <code>&quot;:last-child&quot;</code>, <code>&quot;:nth-child()&quot;</code>, <code>&quot;:nth-last-child()&quot;</code>, etc.<br>
1691 <br>
1692 As of version 2.16.0,
1693 <ul>
1694 <li>The default text extraction method has been renamed and updated to get data from a data-attribute (set by the <a href="#textattribute"><code>textAttribute</code></a> option).</li>
1695 <li>If you need to support older versions of IE, this may add a significant delay to the table initialization especially for large tables; in this case, set the <code>textExtraction</code> option to any name other than "basic".</li>
1696 <li>Also, this option can now be set using a data-attribute named "data-text-extraction" on the table.</li>
1697 </ul>
1698 You can customize the text extraction by writing your own text extraction function "myTextExtraction" which you define like:
1699 <pre class="prettyprint lang-js">var myTextExtraction = function(node, table, cellIndex) {
1700 // extract data from markup and return it
1701 // originally: return node.childNodes[0].childNodes[0].innerHTML;
1702 return $(node).find('selector').text();
1703 }
1704 $(function() {
1705 $("#myTable").tablesorter( { textExtraction: myTextExtraction } );
1706 });</pre>
1707 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).
1708 <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 (<code>1</code> because we are using a zero-based index). All other columns will ignore this textExtraction function.</p>
1709 <p>Added <code>table</code> and <code>cellIndex</code> variables to the <code>textExtraction</code> function in version 2.1.2 (this is not part of the original plugin).</p>
1710 <pre class="prettyprint lang-js">$(function() {
1711 $("table").tablesorter({
1712 textExtraction: {
1713 1: function(node, table, cellIndex) {
1714 return $(node).find("span:last").text();
1715 }
1716 },
1717 headers: {
1718 1: { sorter : "digit" }
1719 }
1720 });
1721 });</pre>
1722 The built-in option is <code>&quot;basic&quot;</code> (modified v2.16.0) which is the equivalent of doing this inside of the textExtraction function: <code>$(node).text();</code>.
1723 </div>
1724 </td>
1725 <td><a href="example-option-text-extraction.html">Example</a></td>
1726 </tr>
1727
1728 <tr id="namespace">
1729 <td><a href="#" class="permalink">namespace</a></td>
1730 <td>String</td>
1731 <td>undefined</td>
1732 <td>
1733 This option should contain a unique namespace for each table; it is used when binding to event listeners (<span class="version">v2.15.7</span>).
1734 <div class="collapsible">
1735 <br>
1736 Notes about this namespace option:
1737 <ul>
1738 <li>If a namesspace is not defined, a (hopefully) unique random namespace will be generated.</li>
1739 <li>If defined, any "non-word" characters (anything not "a-z", "0-9" or "_") within the namespace will be removed.</li>
1740 <li>Added or not, the namespace will be saved with a leading period (e.g. ".myuniquetableid")</li>
1741 </ul>
1742 <pre class="prettyprint lang-js">$(function() {
1743 $("#mytable").tablesorter({
1744 // if table id = "mytable", this namespace is saved as ".mytable"
1745 namespace : $('#mytable')[0].id;
1746 });
1747 });</pre>
1748 </div>
1749 </td>
1750 <td></td>
1751 </tr>
1752
1753 <tr id="numbersorter">
1754 <td><a href="#" class="permalink">numberSorter</a></td>
1755 <td>Function</td>
1756 <td>null</td>
1757 <td>
1758 Replace the default number sorting algorithm with a custom one using this option (<span class="version">v2.12</span>).
1759 <div class="collapsible">
1760 <br>
1761 Here is an example:
1762 <pre class="prettyprint lang-js">$(function() {
1763 $("table").tablesorter({
1764 numberSorter : function(a, b, direction, maxColumnValue) {
1765 // direction; true = ascending; false = descending
1766 // maxColumnValue = the maximum value of that column (ignoring its sign)
1767 return a - b;
1768 }
1769 });
1770 });</pre>The direction parameter (boolean) is merely for informational purposes as the plugin automatically switches <code>a</code> and <code>b</code> depending on the sort direction ( i.e. there's no need to worry about reverse sorting, it's taken care of by the plugin ).
1771 </div>
1772 </td>
1773 <td></td>
1774 </tr>
1775
1776 <tr id="pointerclick">
1777 <td><a href="#" class="permalink">pointerClick</a></td>
1778 <td>String</td>
1779 <td>&quot;click&quot;</td>
1780 <td>Use this option to change the click event (<span class="version">v2.22.0</span>)
1781 <div class="collapsible">
1782 <p>Change this option if want to change the click event that is bound to the table headers. Add multiple events separated by spaces.</p>
1783 <span class="label label-warning">Warning</span> If this option is set to fire multiple events (e.g. <code>'mouseup pointerup'</code>), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
1784 </div>
1785 </td>
1786 <td></td>
1787 </tr>
1788 <tr id="pointerdown">
1789 <td><a href="#" class="permalink">pointerDown</a></td>
1790 <td>String</td>
1791 <td>&quot;mousedown&quot;</td>
1792 <td>Use this option to change the pointer down event (<span class="version">v2.22.0</span>)
1793 <div class="collapsible">
1794 <p>Change this option if you're using pointer events (or the <a class="external" href="https://github.com/jquery/PEP">pointer events polyfill</a>). Add multiple events separated by spaces.</p>
1795 <span class="label label-warning">Warning</span> If this option is set to fire multiple events (e.g. <code>'mousedown pointerdown'</code>), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
1796 </div>
1797 </td>
1798 <td></td>
1799 </tr>
1800 <tr id="pointerup">
1801 <td><a href="#" class="permalink">pointerUp</a></td>
1802 <td>String</td>
1803 <td>&quot;mouseup&quot;</td>
1804 <td>Use this option to change the pointer up event (<span class="version">v2.22.0</span>)
1805 <div class="collapsible">
1806 <p>Change this option if you're using pointer events (or the <a class="external" href="https://github.com/jquery/PEP">pointer events polyfill</a>). Add multiple events separated by spaces.</p>
1807 <span class="label label-warning">Warning</span> If this option is set to fire multiple events (e.g. <code>'mouseup pointerup'</code>), sorting may be initialized twice in rapid succession and make it appear that nothing changed.
1808 </div>
1809 </td>
1810 <td></td>
1811 </tr>
1812
1813 <tr id="textsorter">
1814 <td><a href="#" class="permalink">textSorter</a></td>
1815 <td>Function</td>
1816 <td>null</td>
1817 <td>
1818 Replace the default sorting algorithm with a custom one using this option (<span class="version updated">v2.27.6</span>) - <span class="label label-warning">*NOTE*</span> The parameters have changed!!.
1819 <div class="collapsible">
1820 <br>
1821 Include a script like <a class="external" href="https://github.com/overset/javascript-natural-sort">naturalSort.js</a> as follows:
1822 <pre class="prettyprint lang-js">$(function() {
1823 $("table").tablesorter({
1824 textSorter : naturalSort
1825 });
1826 });</pre>
1827 or use the localeCompare sort
1828 <pre class="prettyprint lang-js">$(function() {
1829 $("table").tablesorter({
1830 // replace the OVERALL text sorter function
1831 textSorter: function(a, b, direction, columnIndex, table) {
1832 // direction: true = ascending; false = descending
1833 // columnIndex: zero-based index of the current table column being sorted
1834 // table: table DOM element (access options by using table.config)
1835 return a.localeCompare(b);
1836 }
1837 });
1838 });</pre>In <span class="version updated">v2.27.6</span>, the <code>textSorter</code> option will allow setting a sorter per column index or class name (column indexes were added in <span class="version updated">v2.12</span>):
1839 <pre class="prettyprint lang-js">$(function() {
1840 $("table").tablesorter({
1841 textSorter : {
1842 // replace INDIVIDUAL COLUMN text sorter functions
1843 0 : function(a, b, direction, columnIndex, table) {
1844 // same as $.tablesorter.sortText (basic alphabetical sort)
1845 // direction: true = ascending; false = descending
1846 // columnIndex: zero-based index of the current table column being sorted
1847 // table: table DOM element (access options by using table.config)
1848 return a &gt; b ? 1 : (a &lt; b ? -1 : 0);
1849 },
1850 // same as the function in column 0 above (modified in v2.12)
1851 1 : $.tablesorter.sortText,
1852 // renamed v2.12 from $.tablesorter.sortText - performs natural sort
1853 '.nat-sort' : $.tablesorter.sortNatural,
1854 // alphanumeric sort from sugar v2.0+ (https://sugarjs.com/docs/#/Array/getOption)
1855 '.sugar-sort' : Sugar.Array.getOption('sortCollate')
1856 }
1857 });
1858 });</pre>The direction parameter (boolean) is merely for informational purposes as the plugin automatically switches <code>a</code> and <code>b</code> depending on the sort direction ( i.e. there's no need to worry about reverse sorting, it's taken care of by the plugin ).
1859 </div>
1860 </td>
1861 <td>
1862 <a href="example-option-custom-sort.html">1</a>
1863 <a href="example-option-textsorter-semver.html">2</a>
1864 </td>
1865 </tr>
1866
1867 <tr id="usnumberformat">
1868 <td><a href="#" class="permalink">usNumberFormat</a></td>
1869 <td>Boolean</td>
1870 <td>true</td>
1871 <td>
1872 Indicates how tablesorter should deal with a numerical format: (v2.1.3).
1873 <div class="collapsible">
1874 <table class="info"><tbody>
1875 <tr>
1876 <th><code>true</code></th>
1877 <td class="right">U.S.</td>
1878 <td><code>1,234,567.89</code></td>
1879 </tr>
1880 <tr>
1881 <th><code>false</code></th>
1882 <td class="right">German:<br>French:</td>
1883 <td><code>1.234.567,89</code><br><code>1 234 567,89</code></td>
1884 </tr>
1885 </tbody></table>
1886 </div>
1887 </td>
1888 <td><a href="../index.html">Example</a></td>
1889 </tr>
1890
1891 <tr id="widgets">
1892 <td><span class="permalink">widgets</span></td>
1893 <td>Array</td>
1894 <td>[ ] (empty array)</td>
1895 <td>
1896 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 ).
1897 </td>
1898 <td><a href="example-widget-zebra.html">Example</a></td>
1899 </tr>
1900
1901 <tr id="widthfixed">
1902 <td><a href="#" class="permalink">widthFixed</a></td>
1903 <td>Boolean</td>
1904 <td>false</td>
1905 <td>
1906 Indicates if tablesorter should apply fixed percentage-based widths to the table columns (modified v2.4).
1907 <div class="collapsible">
1908 Prior to v2.4, this option set pixel widths to added colgroups to fix the column widths. This is useful for the Pager companion.
1909 <br>
1910 <del>Requires the <a href="#Download-Addons">jQuery dimension plugin</a> to work.</del> This is now part of the jQuery core.
1911 </div>
1912 </td>
1913 <td><a href="example-pager.html">Example</a></td>
1914 </tr>
1915
1916 <tr id="widgetoptions">
1917 <td><a href="#" class="permalink">widgetOptions</a></td>
1918 <td>Object</td>
1919 <td>{ }</td>
1920 <td>
1921 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).
1922 <div class="collapsible">
1923 <br>
1924 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>
1925 <br>
1926 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):
1927 <pre class="prettyprint lang-js">$(function() {
1928 $("table").tablesorter({
1929
1930 // initialize a bunch of widgets (the order doesn't matter)
1931 widgets: ["zebra", "uitheme", "columns", "filter", "resizable", "stickyHeaders"],
1932
1933 widgetOptions: {
1934
1935 // *** COLUMNS WIDGET ***
1936 // change the default column class names primary is the 1st column
1937 // sorted, secondary is the 2nd, etc
1938 columns: [
1939 "primary",
1940 "secondary",
1941 "tertiary"
1942 ],
1943
1944 // If true, the class names from the columns option will also be added
1945 // to the table tfoot
1946 columns_tfoot: true,
1947
1948 // If true, the class names from the columns option will also be added
1949 // to the table thead
1950 columns_thead: true,
1951
1952 // *** FILTER WIDGET ***
1953 // css class name added to the filter cell (string or array)
1954 filter_cellFilter: '',
1955
1956 // If there are child rows in the table (rows with class name from
1957 // "cssChildRow" option) and this option is true and a match is found
1958 // anywhere in the child row, then it will make that row visible;
1959 // default is false
1960 filter_childRows: false,
1961
1962 // ( filter_childRows must be true ) if true = search
1963 // child rows by column; false = search all child row text grouped
1964 filter_childByColumn: false,
1965
1966 // if true, include matching child row siblings
1967 filter_childWithSibs: true,
1968
1969 // if true, allows using '#:{query}' in AnyMatch searches
1970 // ( column:query )
1971 filter_columnAnyMatch: true,
1972
1973 // If true, a filter will be added to the top of each table column.
1974 filter_columnFilters: true,
1975
1976 // css class name added to the filter row & each input in the row
1977 // (tablesorter-filter is ALWAYS added)
1978 filter_cssFilter: '',
1979
1980 // data attribute in the header cell that contains the default (initial)
1981 // filter value
1982 filter_defaultAttrib: 'data-value',
1983
1984 // add a default column filter type "~{query}" to make fuzzy searches
1985 // default; "{q1} AND {q2}" to make all searches use a logical AND.
1986 filter_defaultFilter: {},
1987
1988 // filters to exclude, per column
1989 filter_excludeFilter: {},
1990
1991 // jQuery selector string (or jQuery object)
1992 // of external filters
1993 filter_external: '',
1994
1995 // class added to filtered rows; needed by pager plugin
1996 filter_filteredRow: 'filtered',
1997
1998 // ARIA-label added to filter input/select; {{label}} is replaced by
1999 // the column header "data-label" attribute, if it exists, or it uses the
2000 // column header text
2001 filter_filterLabel : 'Filter "{{label}}" column by...',
2002
2003 // add custom filter elements to the filter row
2004 filter_formatter: null,
2005
2006 // Customize the filter widget by adding a select dropdown with content,
2007 // custom options or custom filter functions;
2008 // see http://goo.gl/HQQLW for more details
2009 filter_functions: null,
2010
2011 // hide filter row when table is empty
2012 filter_hideEmpty: true,
2013
2014 // Set this option to true to hide the filter row initially. The row is
2015 // revealed by hovering over the filter row or giving any filter
2016 // input/select focus. In v2.26.6, a function can be used to set when
2017 // to hide the filter row.
2018 filter_hideFilters: false,
2019
2020 // Set this option to false to keep the searches case sensitive
2021 filter_ignoreCase: true,
2022
2023 // if true, search column content while the user types (with a delay)
2024 // or, set a minimum number of characters that must be present before
2025 // a search is initiated. In v2.27.3, this option can contain an
2026 // object with column indexes or classnames; "fallback" is used
2027 // for undefined columns
2028 filter_liveSearch: true,
2029
2030 // global query settings ('exact' or 'match'); overridden by
2031 // "filter-match" or "filter-exact" class
2032 filter_matchType: {
2033 'input': 'exact',
2034 'select': 'exact'
2035 },
2036
2037 // a header with a select dropdown & this class name will only show
2038 // available (visible) options within the drop down
2039 filter_onlyAvail: 'filter-onlyAvail',
2040
2041 // default placeholder text (overridden by any header
2042 // "data-placeholder" setting)
2043 filter_placeholder: {
2044 search: '',
2045 select: ''
2046 },
2047
2048 // jQuery selector string of an element used to reset the filters.
2049 filter_reset: null,
2050
2051 // Reset filter input when the user presses escape
2052 // normalized across browsers
2053 filter_resetOnEsc: true,
2054
2055 // Use the $.tablesorter.storage utility to save the most recent filters
2056 filter_saveFilters: false,
2057
2058 // Delay in milliseconds before the filter widget starts searching;
2059 // This option prevents searching for every character while typing
2060 // and should make searching large tables faster.
2061 filter_searchDelay: 300,
2062
2063 // allow searching through already filtered rows in special
2064 // circumstances; will speed up searching in large tables if true
2065 filter_searchFiltered: true,
2066
2067 // include a function to return an array of values to be added to the
2068 // column filter select
2069 filter_selectSource: null,
2070
2071 // filter_selectSource array text left of the separator is added to
2072 // the option value, right into the option text
2073 filter_selectSourceSeparator: '|',
2074
2075 // Set this option to true if filtering is performed on the
2076 // server-side.
2077 filter_serversideFiltering: false,
2078
2079 // Set this option to true to use the filter to find text from the
2080 // start of the column. So typing in "a" will find "albert" but not
2081 // "frank", both have a's; default is false
2082 filter_startsWith: false,
2083
2084 // If true, ALL filter searches will only use parsed data. To only
2085 // use parsed data in specific columns, set this option to false
2086 // and add class name "filter-parsed" to the header
2087 filter_useParsedData: false,
2088
2089 // *** RESIZABLE WIDGET ***
2090 // If this option is set to false, resized column widths will not
2091 // be saved. Previous saved values will be restored on page reload
2092 resizable: true,
2093
2094 // If this option is set to true, a resizing anchor
2095 // will be included in the last column of the table
2096 resizable_addLastColumn: false,
2097
2098 // If this option is set to true, the resizable handle will extend
2099 // into the table footer
2100 resizable_includeFooter: true,
2101
2102 // Set this option to the starting & reset header widths
2103 resizable_widths: [],
2104
2105 // Set this option to throttle the resizable events
2106 // set to true (5ms) or any number 0-10 range
2107 resizable_throttle: false,
2108
2109 // When true, the last column will be targeted for resizing,
2110 // which is the same has holding the shift and resizing a column
2111 resizable_targetLast: false,
2112
2113 // *** SAVESORT WIDGET ***
2114 // If this option is set to false, new sorts will not be saved.
2115 // Any previous saved sort will be restored on page reload.
2116 saveSort: true,
2117
2118 // *** STICKYHEADERS WIDGET ***
2119 // stickyHeaders widget: extra class name added to the sticky header
2120 // row
2121 stickyHeaders: '',
2122
2123 // jQuery selector or object to append sticky headers to
2124 stickyHeaders_appendTo: null,
2125
2126 // jQuery selector or object to attach sticky headers scroll listener to
2127 // overridden by xScroll & yScroll settings
2128 stickyHeaders_attachTo: null,
2129
2130 // jQuery selector or object to monitor horizontal scroll position
2131 // (defaults: xScroll > attachTo > window)
2132 stickyHeaders_xScroll: null,
2133
2134 // jQuery selector or object to monitor vertical scroll position
2135 // (defaults: yScroll > attachTo > window)
2136 stickyHeaders_yScroll: null,
2137
2138 // number or jquery selector targeting the position:fixed element
2139 stickyHeaders_offset: 0,
2140
2141 // scroll table top into view after filtering
2142 stickyHeaders_filteredToTop: true,
2143
2144 // added to table ID, if it exists
2145 stickyHeaders_cloneId: '-sticky',
2146
2147 // trigger "resize" event on headers
2148 stickyHeaders_addResizeEvent: true,
2149
2150 // if false and a caption exist, it won't be included in the
2151 // sticky header
2152 stickyHeaders_includeCaption: true,
2153
2154 // The zIndex of the stickyHeaders, allows the user to adjust this
2155 // to their needs
2156 stickyHeaders_zIndex: 2,
2157
2158 // *** STORAGE WIDGET ***
2159 // set storage type; this overrides any storage_useSessionStorage setting
2160 // use the first letter of (l)ocal, (s)ession or (c)ookie
2161 storage_storageType: '',
2162 // DEPRECATED: allows switching between using local & session storage
2163 storage_useSessionStorage: false,
2164 // alternate table id (set if grouping multiple tables together)
2165 storage_tableId: '',
2166 // table attribute to get the table ID, if storage_tableId
2167 // is undefined
2168 storage_group: '', // defaults to "data-table-group"
2169 // alternate url to use (set if grouping tables across
2170 // multiple pages)
2171 storage_fixedUrl: '',
2172 // table attribute to get the fixedUrl, if storage_fixedUrl
2173 // is undefined
2174 storage_page: '',
2175
2176 // *** ZEBRA WIDGET ***
2177 // class names to add to alternating rows
2178 // [ "even", "odd" ]
2179 zebra: [
2180 "even",
2181 "odd"
2182 ]
2183
2184 }
2185
2186 });
2187 });</pre></div>
2188 </td>
2189 <td><a href="example-widget-zebra.html">Example</a></td>
2190 </tr>
2191 </tbody>
2192
2193 <!-- non-sorting tbody -->
2194 <tbody id="other" class="tablesorter-infoOnly">
2195 <tr><th colspan="5">Utility Options</th></tr>
2196 </tbody>
2197
2198 <tbody>
2199
2200 <tr id="checkboxclass">
2201 <td><a href="#" class="permalink">checkboxClass</a></td>
2202 <td>String</td>
2203 <td>&quot;checked&quot;</td>
2204 <td>Used by the "checkbox" parser in the <code>parser-input-select.js</code> file (<span class="version">v2.22.2</span>; <span class="version updated">v2.25.0</span>).
2205 <div class="collapsible">
2206 <p>When using the checkbox parser, this class name is added to the row along with this class name plus the column index when the targeted checkbox is checked.</p>
2207 <p>For example, if the named parser file has been loaded &amp; "sorter-checkbox" class is added to the first column header, then any checked checkbox in the first column will have <code>&quot;checked checked-0&quot;</code> class names added to the row.</p>
2208 Checkboxes in any other column, not targeted by the parser, will be ignored and no extra row class names will be added.
2209 </div>
2210 </td>
2211 <td><a href="example-widget-output.html">Example</a></td>
2212 </tr>
2213
2214 <tr id="checkboxvisible">
2215 <td><a href="#" class="permalink">checkboxVisible</a></td>
2216 <td>Boolean</td>
2217 <td>true</td>
2218 <td>Used by the "checkbox" parser in the <code>parser-input-select.js</code> file (<span class="version updated">v2.24.6</span>).
2219 <div class="collapsible">
2220 <p>When using the checkbox parser, this setting is used when a checkbox inside a header cell is changed; if <code>true</code>, only same column checkboxes within visible rows are modified to match the header checkbox.</p>
2221 <p>If <code>false</code>, same column checkboxes in <em>all</em> rows are modified to match the status of the header checkbox.</p>
2222 </div>
2223 </td>
2224 <td><a href="example-widget-output.html">Example</a></td>
2225 </tr>
2226
2227 <tr id="data">
2228 <td><span class="permalink">data</span></td>
2229 <td>Object, Array</td>
2230 <td>undefined</td>
2231 <td>Storage for processed table build widget (<code>widget-build-table.js</code>) data (array, object, string) (<span class="version">v2.11</span>).</td>
2232 <td><a href="example-widget-build-table.html">Example</a></td>
2233 </tr>
2234
2235 <tr id="daterange">
2236 <td><span class="permalink">dateRange</span></td>
2237 <td>Numeric</td>
2238 <td>50</td>
2239 <td>
2240 Used by the two digit year parser (<code>parser-date-two-digit-year.js</code>) to set the date range (<span class="version">v2.14</span>).</td>
2241 <td><a href="example-parsers-dates.html">Example</a></td>
2242 </tr>
2243
2244 <tr id="globalize">
2245 <td><a href="#" class="permalink">globalize</a></td>
2246 <td>object</td>
2247 <td>null</td>
2248 <td>
2249 This option is used by multiple parsers to localize the language (<span class="version">v2.24.0</span>; <span class="version updated">v2.24.1</span>).
2250 <div class="collapsible"><br>
2251 This option is meant to be used with the <a class="external" href="https://github.com/jquery/globalize">jQuery Globalize</a> library along with CLDR data.
2252 <p>See the <a href="example-widget-grouping.html#globalization">Globalization</a> section in the group widget demo for details on how to set it up.</p>
2253 <p>Currently, the globalize (<code>parser-globalize.js</code>), month (<code>parser-date-month.js</code>) &amp; weekday (<code>parser-date-weekday.js</code>) parsers utilize this option.</p>
2254 <pre class="prettyprint lang-js">$(function() {
2255 $('table').tablesorter({
2256 // globalize : { lang: 'en' } // for ALL columns
2257 // or, per column by using the column index
2258 globalize : {
2259 0 : { lang: 'fr', Globalize : Globalize('fr'), raw: 'MMM d, y G' },
2260 2 : { lang: 'fr' }
2261 }
2262 });
2263 });</pre>
2264 </div>
2265 </td>
2266 <td><a href="example-parsers-globalize.html">2</a> <a href="example-parsers-dates.html">2</a></td>
2267 </tr>
2268
2269 <tr id="ignorechildrow">
2270 <td><a href="#" class="permalink">ignoreChildRow</a></td>
2271 <td>Boolean</td>
2272 <td>false</td>
2273 <td>
2274 Used by the input-select parser indicate if changes to child row content is to be ignored (<span class="version">v2.28.10</span>)
2275 <div class="collapsible"><br>
2276 Change this setting to ignore input, textarea and select changes inside of child rows:
2277 <pre class="prettyprint lang-js">$(function() {
2278 $('table').tablesorter({
2279 ignoreChildRow : true
2280 });
2281 });</pre>
2282 See <a href="https://github.com/Mottie/tablesorter/pull/1399">pull request #1399</a> for more information.
2283 </div>
2284 </td>
2285 <td></td>
2286 </tr>
2287
2288 <tr id="imgattr">
2289 <td><a href="#" class="permalink">imgAttr</a></td>
2290 <td>String</td>
2291 <td>&quot;alt&quot;</td>
2292 <td>
2293 Used by the image parser to grab the image attribute content (<span class="version">v2.17.5</span>; moved to tablesorter core in <span class="version updated">v2.18.0</span>; see <a href="#parsers"><code>config.parsers</code></a>).
2294 <div class="collapsible"><br>
2295 Change this setting to grab a different image attribute to be used for sorting:
2296 <pre class="prettyprint lang-js">$(function() {
2297 $('table').tablesorter({
2298 // parse image title (value to be used while sorting & filtering)
2299 imgAttr : 'title',
2300 headers : {
2301 0 : { sorter: 'image' } // this parser is auto-detected, but will only work on the first image
2302 }
2303 });
2304 });</pre>
2305 </div>
2306 </td>
2307 <td></td>
2308 </tr>
2309
2310 </tbody>
2311
2312 <!-- non-sorting tbody -->
2313 <tbody id="deprecated" class="tablesorter-infoOnly">
2314 <tr><th colspan="5">Deprecated/Removed Options</th></tr>
2315 </tbody>
2316
2317 <tbody>
2318
2319 <tr id="fixedurl">
2320 <td><a href="#" class="permalink alert">fixedUrl</a></td>
2321 <td>String</td>
2322 <td>undefined</td>
2323 <td>
2324 This option is being <span class="label label-danger">deprecated</span> in v2.21.3!
2325 It has been replaced by <a href="#widget-storage-fixed-url"><code>widgetOptions.storage_fixedUrl</code></a>; but is still available for backwards compatibility.
2326 <div class="collapsible"><br>
2327 This option was added to set a specific page when storing data using the <a href="#function-storage"><code>$.tablesorter.storage</code></a> code (<span class="version">v2.12</span>).
2328 <br>
2329 More specifically, when the storage function is used, it attempts to give every table a unique identifier using both the page <strong>url</strong> and table <strong>ID</strong> (or index on the page if no id exists). This option allows you to override the current page url (<em>it doesn't need to be a url, just some constant value</em>) and save data for multiple tables across a domain.<br>
2330 <br>
2331 The table url &amp; id can also be overridden by setting table data attributes <code>data-table-page</code> (url) and <code>data-table-group</code> (id)<br>(e.g. <code>&lt;table class=&quot;tablesorter&quot; data-table-page=&quot;mydomain&quot; data-table-group=&quot;financial&quot;&gt;...&lt;/table&gt;</code>)<br>
2332 <br>
2333 For a bit more detail, specifically on how to use the new storage function options for a custom widget, please refer to <a href="https://github.com/Mottie/tablesorter/issues/389#issuecomment-26594259">issue #389</a>.
2334 </div>
2335 </td>
2336 <td></td>
2337 </tr>
2338
2339 <tr id="cssallowclicks">
2340 <td><a href="#" class="permalink alert">cssAllowClicks</a></td>
2341 <td>String</td>
2342 <td></td>
2343 <td>This option was <span class="label label-danger">removed</span>!
2344 It has been replaced by <a href="#cssnosort">cssNoSort</a> which does the opposite of what this class name was supposed to do.
2345 <div class="collapsible">
2346 <p>This option was not working as intended, so it was completely removed - sorry for the lack of notice.</p>
2347 <p>Previous default was <code>&quot;tablesorter-allowClicks&quot;</code></p>
2348 Class name added to table header which allows clicks to bubble up. (added v2.18.1; removed in v2.20.0).
2349 </div>
2350 </td>
2351 <td></td>
2352 </tr>
2353
2354 <tr id="widgetcolumns">
2355 <td><a href="#" class="permalink alert">widgetColumns</a></td>
2356 <td></td>
2357 <td></td>
2358 <td>
2359 This option was <span class="label label-danger">removed</span> in v2.21.2!
2360 It has been replaced by <a href="#widget-columns"><code>widgetOptions.columns</code></a>.
2361 <div class="collapsible">
2362 <br>
2363 Default value: <code>{ css: [ "primary", "secondary", "tertiary" ] }</code> (Object with Array)
2364 <p></p>
2365 When the column styling widget is initialized, it automatically applied the default class names of <code>&quot;primary&quot;</code> for the primary sort, <code>&quot;secondary&quot;</code> for the next sort, <code>&quot;tertiary&quot;</code> for the next sort, and so on (add more as needed)... (v2.0.17).
2366 Use the <a href="#widgetcolumns"><code>widgetColumns</code></a> option to change the css class name as follows:
2367 <pre class="prettyprint lang-js">$(function() {
2368 $("table").tablesorter({
2369 widgets: ["columns"], // initialize column styling of the table
2370 widgetColumns: { css: ["primary", "secondary", "tertiary" ] }
2371 });
2372 });</pre></div>
2373 </td>
2374 <td></td>
2375 </tr>
2376
2377 <tr id="widgetuitheme">
2378 <td><a href="#" class="permalink alert">widgetUitheme</a></td>
2379 <td></td>
2380 <td></td>
2381 <td>
2382 This option was <span class="label label-danger">removed</span> in v2.4!
2383 It has been replaced by <a href="#widget-uitheme"><code>widgetOptions.uitheme</code></a>.
2384 <div class="collapsible">
2385 <br>
2386 Default value: <code>{ css: [ "ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n" ] }</code> (Object with Array)
2387 <p></p>
2388 Used when the ui theme styling widget is initialized. It automatically applies the default class names of <code>&quot;ui-icon-arrowthick-2-n-s&quot;</code> for the unsorted column, <code>&quot;ui-icon-arrowthick-1-s&quot;</code> for the descending sort and <code>&quot;ui-icon-arrowthick-1-n&quot;</code> for the ascending sort. (v2.0.9).
2389 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>
2390 <br>
2391 Use the <a href="#widgetuitheme"><code>widgetUitheme</code></a> option to change the css class name as follows:
2392 <pre class="prettyprint lang-js">$(function() {
2393 $("table").tablesorter({
2394 widgets: ["uitheme"], // initialize ui theme styling widget of the table
2395 widgetUitheme: {
2396 css: [
2397 "ui-icon-carat-2-n-s", // Unsorted icon
2398 "ui-icon-carat-1-s", // Sort up (down arrow)
2399 "ui-icon-carat-1-n" // Sort down (up arrow)
2400 ]
2401 }
2402 });
2403 });</pre></div>
2404 </td>
2405 <td></td>
2406 </tr>
2407
2408 <tr id="widgetzebra">
2409 <td><a href="#" class="permalink alert">widgetZebra</a></td>
2410 <td></td>
2411 <td></td>
2412 <td>
2413 This option was <span class="label label-danger">removed</span> in v2.4!
2414 It has been replaced by <a href="#widget-zebra"><code>widgetOptions.zebra</code></a>.
2415 <div class="collapsible">
2416 <br>
2417 Default value: <code>{ css: [ &quot;even&quot;, &quot;odd&quot; ] }</code> (Object with Array)
2418 <p></p>
2419 When the zebra striping widget is initialized, it automatically applied the default class names of <code>&quot;even&quot;</code> and <code>&quot;odd&quot;</code>.
2420 Use the <a href="#widgetzebra"><code>widgetZebra</code></a> option to change the css class name as follows:
2421 <pre class="prettyprint lang-js">$(function() {
2422 $("table").tablesorter({
2423 widgets: ["zebra"], // initialize zebra striping of the table
2424 widgetZebra: { css: [ "normal-row", "alt-row" ] }
2425 });
2426 });</pre></div>
2427 </td>
2428 <td></td>
2429 </tr>
2430
2431 </tbody>
2432 </table>
2433
2434 <a id="Widget-options"></a>
2435 <h1>Widget &amp; Pager Options</h1>
2436
2437 <table class="tablesorter-blue compatibility" data-sortlist="[[0,0]]">
2438 <thead>
2439 <tr><th>Widget Priority</th><th>Name</th><th>Requires jQuery</th><th>Limiting function</th></tr>
2440 </thead>
2441 <tbody>
2442 <tr><td>30</td><td>columns</td><td>v1.2.6</td><td></td></tr>
2443 <tr><td>50</td><td>filter</td><td>v1.4.3</td><td>1.4.3 (nextUntil &amp; delegate)</td></tr>
2444 <tr><td>Last</td><td>pager plugin</td><td>v1.2.6</td><td></td></tr>
2445 <tr><td>55</td><td>pager widget</td><td>v1.7</td><td>1.7 (on)</td></tr>
2446 <tr><td>40</td><td>resizable</td><td>v1.4.1*</td><td>1.4.1 (parseJSON)*</td></tr>
2447 <tr><td>20</td><td>saveSort</td><td>v1.4.1</td><td>1.4.1 (parseJSON)*</td></tr>
2448 <tr><td>60</td><td>stickyHeaders</td><td>v1.4.3</td><td>1.4.3 (isWindow)**</td></tr>
2449 <tr><td>10</td><td>uitheme</td><td>v1.2.6</td><td></td></tr>
2450 <tr><td>90</td><td>zebra</td><td>v1.2.6</td><td></td></tr>
2451 </tbody>
2452 </table>
2453
2454 <div class="tip">
2455 <p></p>
2456 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:
2457 <ul>
2458 <li>The applied order of widget is dependent of the widget priority, from low to high.</li>
2459 <li>Widget priority values do not need to be unique. Any new widget without a defined priority will automatically have a priority of <code>10</code>.</li>
2460 <li>The pager, being a plugin, is actually initialized after tablesorter has initialized and all selected widgets applied.</li>
2461 <li>* The <code>saveSort</code> and <code>resizable</code> widgets use the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function by default and thus need the <code>parseJSON</code> function which is available in jQuery 1.4.1+.</li>
2462 <li>** The <code>stickyHeaders</code> widget was updated in v2.18.0 to use <code>$.isWindow</code> for the <code>xScroll</code> &amp; <code>yScroll</code> options; and therefore now requires jQuery 1.4.3+.</li>
2463 </ul>
2464
2465 <br class="clear">
2466 <span class="label label-info">TIP!</span> 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.
2467 </div>
2468
2469 <table id="widget-options" class="tablesorter-blue options" data-sortlist="[[0,0]]">
2470 <thead>
2471 <tr>
2472 <th class="property">Property</th>
2473 <th class="type">Type</th>
2474 <th class="defaults">Default</th>
2475 <th class="descrip sorter-false">Description</th>
2476 <th class="examples sorter-false">Link</th>
2477 </tr>
2478 </thead>
2479 <tfoot>
2480 <tr>
2481 <th class="property">Property</th>
2482 <th class="type">Type</th>
2483 <th class="defaults">Default</th>
2484 <th class="descrip">Description</th>
2485 <th class="examples">Link</th>
2486 </tr>
2487 </tfoot>
2488 <tbody>
2489
2490 <tr id="widget-columns">
2491 <td><a href="#" class="permalink">columns</a></td>
2492 <td>Array</td>
2493 <td>[ "primary", "secondary", "tertiary" ]</td>
2494 <td>
2495 Columns widget: When the column styling widget is initialized, it automatically applied the default class names of <code>&quot;primary&quot;</code> for the primary sort, <code>&quot;secondary&quot;</code> for the next sort, <code>&quot;tertiary&quot;</code> for the next sort, and so on (add more as needed)... (Modified v2.1).
2496 <div class="collapsible">
2497 <br>
2498 Use the <a href="#widget-columns"><code>&quot;columns&quot;</code></a> option to change the css class name as follows:
2499 <pre class="prettyprint lang-js">$(function() {
2500 $("table").tablesorter({
2501 widgets: ["columns"], // initialize column styling of the table
2502 widgetOptions : {
2503 columns: [ "primary", "secondary", "tertiary" ]
2504 }
2505 });
2506 });</pre></div>
2507 </td>
2508 <td><a href="example-widget-columns.html">Example</a></td>
2509 </tr>
2510
2511 <tr id="widget-columns-thead">
2512 <td><a href="#" class="permalink">columns_thead</a></td>
2513 <td>Boolean</td>
2514 <td>true</td>
2515 <td>
2516 Columns widget: If true, the class names from the <a href="#widget-columns"><code>columns</code></a> option will also be added to the table thead (v2.4).
2517 <div class="collapsible">
2518 <br>
2519 Use the <a href="#widget-columns-thead"><code>&quot;columns_thead&quot;</code></a> option to add the column class names to the thead as follows:
2520 <pre class="prettyprint lang-js">$(function() {
2521 $("table").tablesorter({
2522 widgets: ["columns"], // initialize column styling of the table
2523 widgetOptions : {
2524 columns_thead: true
2525 }
2526 });
2527 });</pre></div>
2528 </td>
2529 <td><a href="example-widget-columns.html">Example</a></td>
2530 </tr>
2531
2532 <tr id="widget-columns-tfoot">
2533 <td><a href="#" class="permalink">columns_tfoot</a></td>
2534 <td>Boolean</td>
2535 <td>true</td>
2536 <td>
2537 Columns widget: If true, the class names from the <a href="#widget-columns"><code>columns</code></a> option will also be added to the table tfoot (v2.4).
2538 <div class="collapsible">
2539 <br>
2540 Use the <a href="#widget-columns-tfoot"><code>&quot;columns_tfoot&quot;</code></a> option to add the column class names to the tfoot as follows:
2541 <pre class="prettyprint lang-js">$(function() {
2542 $("table").tablesorter({
2543 widgets: ["columns"], // initialize column styling of the table
2544 widgetOptions : {
2545 columns_tfoot: true
2546 }
2547 });
2548 });</pre></div>
2549 </td>
2550 <td><a href="example-widget-columns.html">Example</a></td>
2551 </tr>
2552
2553 <tr id="widget-filter-childrows">
2554 <td><a href="#" class="permalink">filter_childRows</a></td>
2555 <td>Boolean</td>
2556 <td>false</td>
2557 <td>
2558 Filter widget: If there are child rows in the table (rows with class name from <a href="#csschildrow"><code>&quot;cssChildRow&quot;</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.
2559 (Modified v2.1).
2560 <div class="collapsible">
2561 <p><span class="label label-info">*NOTE*</span> When using this option, please be aware that all child row content will be obtained from each table cell using <code>textContent</code>, so none of the markup will be preserved. Also, carriage returns (<code>&lt;br&gt;</code>) will not be included. To account for the loss of white space, especially after carriage returns, please add an extra space to the end of the line. Using <code>innerText</code>, could have been an option for preserving the white space, but it is not standardized across all browsers (<a class="external" href="http://perfectionkills.com/the-poor-misunderstood-innerText/">ref</a>).</p>
2562 Use the <a href="#widget-filter-childrows"><code>filter_childRows</code></a> option to include child row text as follows:
2563 <pre class="prettyprint lang-js">$(function() {
2564 $("table").tablesorter({
2565 widgets: ["filter"],
2566 widgetOptions : {
2567 filter_childRows : true
2568 }
2569 });
2570 });</pre></div>
2571 </td>
2572 <td></td>
2573 </tr>
2574
2575 <tr id="widget-filter-child-by-column">
2576 <td><a href="#" class="permalink">filter_childByColumn</a></td>
2577 <td>Boolean</td>
2578 <td>false</td>
2579 <td>
2580 Filter widget: If <code>true</code>, queries will search child row content by column (<span class="version">v2.22.0</span>).
2581 <div class="collapsible">
2582 <p>The <code>filter_childRows</code> option must also be <code>true</code> for this option to work.</p>
2583 <p>If <code>false</code>, and the <code>filter_childRows</code> option is <code>true</code>, then queries in <em>any column</em> will search all child content, as before this option was added.</p>
2584 <p></p>
2585 Use the <a href="#widget-filter-child-by-column"><code>filter_childByColumn</code></a> option as follows:
2586 <pre class="prettyprint lang-js">$(function() {
2587 $("table").tablesorter({
2588 widgets: ["filter"],
2589 widgetOptions : {
2590 filter_childRows : true,
2591 filter_childByColumn : true
2592 }
2593 });
2594 });</pre>
2595 </div>
2596 </td>
2597 <td><a href="example-child-rows-filtered.html#child-by-column">Example</a></td>
2598 </tr>
2599
2600 <tr id="widget-filter-child-with-sibs">
2601 <td><a href="#" class="permalink">filter_childWithSibs</a></td>
2602 <td>Boolean</td>
2603 <td>true</td>
2604 <td>
2605 Filter widget: include all sibling rows of the matching child row (<span class="version">v2.23.4</span>).
2606 <div class="collapsible">
2607 <p>Both <code>filter_childRows</code> &amp; <code>filter_childByColumn</code> options must be set to <code>true</code> for this option to work.</p>
2608 <p>If <code>false</code>, this option will only show the child row that matches the filter; and its parent row.</p>
2609 Use the <a href="#widget-filter-child-with-sibs"><code>filter_childWithSibs</code></a> option as follows:
2610 <pre class="prettyprint lang-js">$(function() {
2611 $("table").tablesorter({
2612 widgets: [ "filter" ],
2613 widgetOptions : {
2614 filter_childRows : true,
2615 filter_childByColumn : true,
2616 // only show matching child row & parent
2617 filter_childWithSibs : false
2618 }
2619 });
2620 });</pre>
2621 </div>
2622 </td>
2623 <td><a href="example-widget-filter-childrows.html">Example</a></td>
2624 </tr>
2625
2626 <tr id="widget-filter-column-anymatch">
2627 <td><a href="#" class="permalink">filter_columnAnyMatch</a></td>
2628 <td>Boolean</td>
2629 <td>true</td>
2630 <td>
2631 Filter widget: If <code>true</code>, allows using "#:{query}" in anyMatch searches (<span class="version">v2.20.0</span>).
2632 <div class="collapsible">
2633 <br>
2634 Users can use the anymatch input to target a specific column, using a one-based index.
2635 <p></p>
2636 For example: In the table below, searching for <code>2:aa</code> in an anymatch filter will result in "Phillip Aaron Wong" and "Aaron" showing in the First Name column.
2637 <p></p>
2638 See live examples in the <a href="example-widget-filter-any-match.html#anymatch_searches">Filter Widget External Search</a> demo.
2639 </div>
2640 </td>
2641 <td></td>
2642 </tr>
2643
2644 <tr id="widget-filter-columnfilters">
2645 <td><a href="#" class="permalink">filter_columnFilters</a></td>
2646 <td>Boolean</td>
2647 <td>true</td>
2648 <td>
2649 Filter widget: If <code>true</code>, a filter will be added to the top of each table column (v2.4).
2650 <div class="collapsible">
2651 <br>
2652 Use the <a href="#widget-filter-columnFilters"><code>filter_columnFilters</code></a> option as follows:
2653 <pre class="prettyprint lang-js">$(function() {
2654 $("table").tablesorter({
2655 widgets: ["filter"],
2656 widgetOptions : {
2657 filter_columnFilters : true
2658 }
2659 });
2660 });</pre></div>
2661 </td>
2662 <td></td>
2663 </tr>
2664
2665 <tr id="widget-filter-cellfilter">
2666 <td><a href="#" class="permalink">filter_cellFilter</a></td>
2667 <td>String or Array</td>
2668 <td>&quot;&quot;</td>
2669 <td>Filter widget: Additional CSS class applied to each filter cell (<span class="version">v2.18.0</span>).
2670 <div class="collapsible"><br>
2671 When the filter row is built, each table cell (<code>&lt;td&gt;</code>) will get the class name from this option.
2672 <ul>
2673 <li>If this option is a plain string, all filter row cells will get the text applied as a class name.
2674 <pre class="prettyprint lang-js">// "table-filter-cell" class added to all filter row td's
2675 filter_cellFilter : 'table-filter-cell'</pre>
2676 </li>
2677 <li>If this option is an array, then each filter row cell will get the text from the associate array element applied as a class name.
2678 <pre class="prettyprint lang-css">.hidden { display: none; }</pre>
2679 <pre class="prettyprint lang-js">// hiding second & fourth columns using associated css
2680 filter_cellFilter : [ '', 'hidden', '', 'hidden' ]</pre>
2681 </li>
2682 </ul>
2683 <p>Use the <a href="#widget-filter-cellfilter"><code>filter_cellFilter</code></a> option to add an extra css class name as follows:</p>
2684 <pre class="prettyprint lang-js">$(function() {
2685 $("table").tablesorter({
2686 widgets: ["filter"],
2687 widgetOptions : {
2688 // css class applied to the table row containing the filters & the inputs within that row
2689 // or [ "filter-cell0", "filter-cell1", "filter-cell2", etc... ]
2690 filter_cellFilter : "tablesorter-filter-cell"
2691 }
2692 });
2693 });</pre><span class="label label-info">Note</span> The cells from this option are also contained within the <a href="#variable-filters"><code>config.$filters</code></a> variable.
2694 </div>
2695 </td>
2696 <td><a href="example-widget-filter.html">Example</a></td>
2697 </tr>
2698
2699 <tr id="widget-filter-cssfilter">
2700 <td><a href="#" class="permalink">filter_cssFilter</a></td>
2701 <td>String or Array</td>
2702 <td>&quot;&quot;</td>
2703 <td>Filter widget: Additional CSS class applied to each filter (<span class="version updated">v2.15</span>).
2704 <div class="collapsible"><br>
2705 As of v2.15, this option can also contain an array of class names that are to be applied to input filters.<br>
2706 <br>
2707 Changed default to an empty string in v2.11, as the <code>&quot;tablesorter-filter&quot;</code> class will always be added to the filter; this option now contains any additional class names to add.
2708 <p>Use the <a href="#widget-filter-cssfilter"><code>filter_cssFilter</code></a> option to add an extra css class name as follows:</p>
2709 <pre class="prettyprint lang-js">$(function() {
2710 $("table").tablesorter({
2711 widgets: ["filter"],
2712 widgetOptions : {
2713 // css class applied to the table row containing the filters & the inputs within that row
2714 // or [ "filter0", "filter1", "filter2", etc... ]
2715 filter_cssFilter : "tablesorter-filter"
2716 }
2717 });
2718 });</pre>
2719 </div>
2720 </td>
2721 <td><a href="example-widget-filter.html">Example</a></td>
2722 </tr>
2723
2724 <tr id="widget-defaultfilter">
2725 <td><a href="#" class="permalink">filter_defaultFilter</a></td>
2726 <td>Object</td>
2727 <td>{ }</td>
2728 <td>
2729 Filter widget: Add a default filter type to a column (<span class="version">v2.17.8</span>).
2730 <div class="collapsible">
2731 <br>
2732 <span class="label warning">Warning</span> If a column has a default filter set, the user <strong>will not</strong> be able to use other filters.<br>
2733 <br>
2734 Use the <a href="#widget-defaultfilter"><code>filter_defaultFilter</code></a> option as follows:
2735 <pre class="prettyprint lang-js">$(function() {
2736 $("table").tablesorter({
2737 widgets: ["filter"],
2738 widgetOptions : {
2739
2740 filter_defaultFilter : {
2741 // target a column by class name or column index (zero-based)
2742
2743 '.fuzzy' : '~{q}',
2744 2 : '{q}=',
2745
2746 // for default "anyMatches" use the column length as the index
2747 // e.g. if your table has 5 columns (0,1,2,3,4), then set the anyMatch column as 5.
2748 5 : '{q} or {q}' // any match column
2749 }
2750
2751 }
2752 });
2753 });</pre>
2754 Set up the column string as follows:
2755 <ul>
2756 <li>Add the desired filter type symbol along with <code>{query}</code> or <code>{q}</code> to maintain positioning</li>
2757 <li>Symbols can be added to the beginning <code>&quot;~{query}&quot;</code> (default fuzzy search) or end <code>&quot;{q}=&quot;</code> (default exact search)</li>
2758 <li>For symbols that separate queries, like "AND", "OR" or "-" (range):
2759 <ul>
2760 <li>Add one additional <code>{q}</code> tag.</li>
2761 <li>For example, to add a default "OR" search, use <code>&quot;{q} OR {q}&quot;</code>.</li>
2762 <li>If the user enters <code>&quot;a b c d&quot;</code> the column will be filtered using <code>&quot;a OR b OR c OR d&quot;</code>, so there is no need to add more <code>{q}</code> tags within the string; adding more will likely mess up the results.</li>
2763 <li>If the user only enters <code>&quot;a&quot;</code>, then the column will be filtered using <code>&quot;a OR a&quot;</code> so as not to cause other issues.</li>
2764 </ul>
2765 </li>
2766 <li><span class="label label-info">Note</span> It is not possible to set up a default filter search within a query. So the "wild" filter search will not work as intended (e.g. <code>{q}*</code> and <code>{q}?</code> are essentially the same as <code>{q}</code>.</li>
2767 </ul>
2768 </div>
2769 </td>
2770 <td><a href="example-widget-filter-any-match.html">Example</a></td>
2771 </tr>
2772
2773 <tr id="widget-filter-exclude-filter">
2774 <td><a href="#" class="permalink">filter_excludeFilter</a></td>
2775 <td>Object</td>
2776 <td>{ }</td>
2777 <td>Filter widget: Additional CSS class applied to each filter (<span class="version">v2.17.8</span>).
2778 Exclude a filter type(s) for a column.
2779 <div class="collapsible">
2780 <br>
2781 Use the <a href="#widget-excludefilter"><code>filter_excludeFilter</code></a> option as follows:
2782 <pre class="prettyprint lang-js">$(function() {
2783 $("table").tablesorter({
2784 widgets: ["filter"],
2785 widgetOptions : {
2786
2787 filter_excludeFilter : {
2788 // target a column by class name or column index (zero-based)
2789 '.title' : 'range',
2790
2791 // separate multiple filter types using spaces
2792 2 : 'range notMatch exact'
2793 }
2794
2795 }
2796 });
2797 });</pre>
2798 Exclusion names must be separated by a comma. Here is a full list of filter type names:
2799 <ul>
2800 <li><code>and</code> - logical AND type filter (using <code>foo AND bar</code> or <code>foo && bar</code>).</li>
2801 <li><code>or</code> - logical OR type filter (using <code>foo OR bar</code> or <code>foo|bar</code>).</li>
2802 <li><code>exact</code> - exact match (using <code>&quot;</code> or <code>=</code>).</li>
2803 <li><code>fuzzy</code> - fuzzy match (<code>~</code>)</li>
2804 <li><code>notMatch</code> - not match (<code>!</code> or <code>!=</code>)</li>
2805 <li><code>operators</code> - comparison filters (<code>&lt; &lt;= &gt;= &gt;</code>)</li>
2806 <li><code>range</code> - range (<code> - </code> or <code> to </code>)</li>
2807 <li><code>regex</code> - regex (<code>/\d/</code>)</li>
2808 <li><code>wild</code> - wild card matching (<code>?</code> for single characters, <code>*</code> for multiple characters not including spaces, <del>or <code>|</code> or <code> OR </code> for a logical OR</del> (the "or" filter type was separated from "wild" in v2.22.2).</li>
2809 </ul>
2810 </div>
2811 </td>
2812 <td></td>
2813 </tr>
2814
2815 <tr id="widget-filter-external">
2816 <td><a href="#" class="permalink">filter_external</a></td>
2817 <td>String</td>
2818 <td>&quot;&quot;</td>
2819 <td>
2820 Filter widget: jQuery selector string of inputs, outside of the table, to be used for searching table content (<span class="version">v2.15</span>).
2821 <div class="collapsible">
2822 <br>
2823 Set this option to be a jQuery selector string, or jQuery object, pointing to any external inputs that are to be used for searching the table.<br>
2824 <br>
2825 Use the <a href="#widget-filter-external"><code>filter_external</code></a> option as follows:
2826 <pre class="prettyprint lang-js">$(function() {
2827 $("table").tablesorter({
2828 widgets: ["filter"],
2829 widgetOptions : {
2830 filter_external : '.search'
2831 }
2832 });
2833 });</pre>
2834 These external inputs have one requirement, they must have a <code>data-column=&quot;#&quot;</code>, where the <code>#</code> targets the column (zero-based index), pointing to a specific column to search.<br>
2835 <pre class="prettyprint lang-html">&lt;input class=&quot;search&quot; type=&quot;search&quot; data-column=&quot;0&quot; placeholder=&quot;Search first column&quot;&gt;</pre>
2836 If you want to search all columns, using the updated "any match" method, set the data column value to "all":<br>
2837 <pre class="prettyprint lang-html">&lt;input class=&quot;search&quot; type=&quot;search&quot; data-column=&quot;all&quot; placeholder=&quot;Search entire table&quot;&gt;</pre>
2838 The updated any matching code will now automatically update all associated inputs with the latest search.
2839 <br>
2840 This option replaces <a href="#widget-filter-anymatch"><code>filter_anyMatch</code></a>.
2841 </div>
2842 </td>
2843 <td><a href="example-widget-filter-any-match.html">Example</a></td>
2844 </tr>
2845
2846 <tr id="widget-filter-filteredrow">
2847 <td><a href="#" class="permalink">filter_filteredRow</a></td>
2848 <td>String</td>
2849 <td>&quot;filtered&quot;</td>
2850 <td>
2851 Filter widget: This is the class name applied to all rows that do not match the filter (hidden rows); used by pager plugin (<span class="version">v2.10</span>).
2852 <div class="collapsible">
2853 <br>
2854 <span class="label alert">*NOTE*</span> If creating a custom theme, make sure to include this definition (set to <code>display:none</code> or the filter widget will appear to be broken!
2855 </div>
2856 </td>
2857 <td></td>
2858 </tr>
2859
2860 <tr id="widget-filter-filterlabel">
2861 <td><a href="#" class="permalink">filter_filterLabel</a></td>
2862 <td>String</td>
2863 <td>'Filter "{{label}}" column by...'</td>
2864 <td>
2865 This option contains the ARIA-label value to be added to the filter input or select (<span class="version">v2.29.4</span>).
2866 <div class="collapsible">
2867 <p>
2868 By default, a <code>{{label}}</code> is included in the setting to insert a column label. The content is obtained from the header cell's <code>data-label</code> attribute (do not include the <code>data-</code> prefix), if it exists, or the column header text. See the "First Name" column on the example page.
2869 </p>
2870 <p>
2871 More complex labels may be included by adding multiple "data-attributes". For example, the following option:
2872 <pre class="pretty-print lang-js">filter_filterLabel : 'Filter the {{column-name}}, the {{ordinal-number}} column{{label-extra}}{{default-filter}}'</pre>
2873 with this header cell HTML
2874 <pre class="pretty-print lang-html">&lt;th data-column-name="last name" data-ordinal-number="second" data-default-filter=", using a fuzzy search" data-label-extra=""&gt;
2875 Last
2876 &lt;th&gt;</pre>
2877 would result in an ARIA-label of <code>'Filter the last name, the second column, using a fuzzy search'</code>
2878 </p>
2879 <span class="label label-info">Note:</span>
2880 <ul>
2881 <li>The <code>data-</code> prefix must not be added in the placeholders.</li>
2882 <li>The empty <code>data-label-extra</code> attribute did add any content to the resulting label.</li>
2883 <li>If an included data-attribute does not exist on the header, it will be replaced by the header text.</li>
2884 </ul>
2885 </div>
2886 </td>
2887 <td><a href="example-widget-filter.html#demo">Example</a></td>
2888 </tr>
2889
2890 <tr id="widget-filter-formatter">
2891 <td><a href="#" class="permalink">filter_formatter</a></td>
2892 <td>Object</td>
2893 <td>null</td>
2894 <td>
2895 Filter widget: This option allows you to add custom controls within the filter widget row (v2.7.7; <span class="version updated">v2.17.0</span>).<br>
2896 <div class="collapsible">
2897 <br>
2898 In <span class="version updated">v2.17.0</span>, the <code>filter_formatter</code> column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table <em>header</em> cell.<br>
2899 <pre class="prettyprint lang-js">filter_formatter : {
2900 ".col-value" : function($cell, indx) {
2901 return $.tablesorter.filterFormatter.uiSpinner( $cell, indx, {
2902 ...
2903 });
2904 }
2905 }</pre>
2906 <span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>&quot;th:eq()&quot;</code>, <code>&quot;:gt()&quot;</code>, <code>&quot;:lt()&quot;</code>, <code>&quot;:first&quot;</code>, <code>&quot;:last&quot;</code>, <code>&quot;:even&quot;</code> or <code>&quot;:odd&quot;</code>, <code>&quot;:first-child&quot;</code>, <code>&quot;:last-child&quot;</code>, <code>&quot;:nth-child()&quot;</code>, <code>&quot;:nth-last-child()&quot;</code>, etc.<br>
2907 <br>
2908 A new file has been included named "widget-filter-formatter-jui.js" &amp; "widget-filter-formatter-html5.js". The files include code to add jQuery UI and HTML5 controls via the <a href="#widget-filter-formatter"><code>filter_formatter</code></a> option.<br>
2909 <br>
2910 Most of the formatter functions have an option named <code>valueToHeader</code> which, when <code>true</code> adds a span to the header cell above the filter row and updates it with the current control's value (see <a href="example-widget-filter-formatter-2.html">example 2</a>). If the option exists and is set to <code>false</code>, then the current value is added to the control's handle and css can be used to create a popup to show the current value (see <a href="example-widget-filter-formatter-1.html">example 1</a>).<br>
2911 <br>
2912 Another custom option named <code>addToggle</code> is included with the "uiSpinner", "html5Color" and "html5Number" code. This allows the user to disable the control to show all table rows. For the single sliders, "uiSlider" and "html5Range", the minimum value is used to clear the filter (show all rows).<br>
2913 <br>
2914 The options included for each jQuery UI control only show basic options, but any or all of the jQuery UI options for that control can be included.<br>
2915 <ul>
2916 <li>
2917 To add the jQuery UI slider, follow this example:
2918 <pre class="prettyprint lang-js">$(function() {
2919 $("table").tablesorter({
2920 widgets: ["filter"],
2921 widgetOptions : {
2922 filter_formatter : {
2923 // column index `0` or use a jQuery selector `"th:contains('Discount')"`
2924 0 : function($cell, indx) {
2925 return $.tablesorter.filterFormatter.uiSpinner( $cell, indx, {
2926 value : 0, // starting value
2927 min : 0, // minimum value
2928 max : 50, // maximum value
2929 step : 1, // increment value by
2930 addToggle: true, // Add a toggle to enable/disable the control
2931 valueToHeader: false // add current slider value to the header cell
2932 });
2933 }
2934 }
2935 }
2936 });
2937 });</pre>Any of the other <a class="external" href="http://api.jqueryui.com/spinner/">jQuery UI spinner widget options</a> can also be included.<br>
2938 <br>
2939 </li>
2940 <li>Filter formatter functions include: "uiSpinner", "uiSlider", "uiRange" (uiSlider ranged), "uiDatepicker" (range only), "html5Number", "html5Range" and "html5Color".</li>
2941 <li>
2942 For other examples, please refer to the example pages. Formatter part 1 (example 1) adds jQuery UI controls to the filter row, while formatter part 2 (example 2) adds HTML5 controls, if supported, to the filter row.
2943 </li>
2944 </ul>
2945 </div>
2946 </td>
2947 <td>
2948 <a href="example-widget-filter-formatter-1.html">1</a>
2949 <a href="example-widget-filter-formatter-2.html">2</a>
2950 </td>
2951 </tr>
2952
2953 <tr id="widget-filter-functions">
2954 <td><a href="#" class="permalink">filter_functions</a></td>
2955 <td>Object</td>
2956 <td>null</td>
2957 <td>
2958 Filter widget: Customize the filter widget by adding a select dropdown with content, custom options or custom filter functions (v2.3.6; <span class="version updated">v2.17.0</span>).
2959 <div class="collapsible">
2960 <br>
2961 In <span class="version updated">v2.22.0</span>, a <a href="example-widget-filter-custom-search.html#how_to_add_custom_filter_types"><code>data</code></a> parameter was added to that long list of parameters.<p></p>
2962 <span class="label alert">*WARNING*</span> In a future update, the filter function parameters will be cleaned up and changed as follows!
2963 <pre class="prettyprint lang-js">filter_functions : {
2964 // function(e, n, f, i, $r, c, data) {} &lt;- current parameters
2965 0 : function(c, data) {} // planned change (version undetermined)
2966 }</pre>The <code>e</code> (exact table cell text), <code>n</code> (normalized table cell text), <code>f</code> (filter input value), <code>i</code> (column index) and <code>$r</code> (current row; jQuery object) are all already included in the <a href="example-widget-filter-custom-search.html#how_to_add_custom_filter_types"><code>data</code></a> object.
2967 <p></p>
2968 In <span class="version updated">v2.17.0</span>, the <code>filter_functions</code> column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table <em>header</em> cell.<br>
2969 <pre class="prettyprint lang-js">filter_functions : {
2970 ".col-date" : {
2971 "&lt; 2004" : function (e, n, f, i, $r, c, data) {
2972 return n &lt; Date.UTC(2004, 0, 1); // &lt; Jan 1 2004
2973 },
2974 ...
2975 }
2976 }</pre>
2977 <span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>&quot;th:eq()&quot;</code>, <code>&quot;:gt()&quot;</code>, <code>&quot;:lt()&quot;</code>, <code>&quot;:first&quot;</code>, <code>&quot;:last&quot;</code>, <code>&quot;:even&quot;</code> or <code>&quot;:odd&quot;</code>, <code>&quot;:first-child&quot;</code>, <code>&quot;:last-child&quot;</code>, <code>&quot;:nth-child()&quot;</code>, <code>&quot;:nth-last-child()&quot;</code>, etc.<br>
2978 <br>
2979 Use the <a href="#widget-filter-functions"><code>&quot;filter_functions&quot;</code></a> option in three different ways:
2980 <br>
2981 <ul>
2982 <li>
2983 Make a sorted select dropdown list of all column contents. Repeated content will be combined.
2984 <pre class="prettyprint lang-js">$(function() {
2985 $("table").tablesorter({
2986 widgets: ["filter"],
2987 widgetOptions: {
2988 filter_functions: {
2989 // Add select menu to this column
2990 // set the column value to true, and/or add "filter-select" class name to header
2991 0 : true
2992 }
2993 }
2994 });
2995 });</pre>
2996 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>
2997 </li>
2998 <li>
2999 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.
3000
3001 <h4>Regex example</h4>
3002 <pre class="prettyprint lang-js">$(function() {
3003 $("table").tablesorter({
3004 widgets: ["filter"],
3005 widgetOptions: {
3006 // function variables:
3007 // e = exact text from cell
3008 // n = normalized value returned by the column parser
3009 // f = search filter input value
3010 // i = column index
3011 // $r = jQuery element of current row
3012 // c = table.config
3013 // data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
3014 filter_functions: {
3015 // Add these options to the select dropdown (regex example)
3016 2 : {
3017 "A - D" : function(e, n, f, i, $r, c, data) { return /^[A-D]/.test(e); },
3018 "E - H" : function(e, n, f, i, $r, c, data) { return /^[E-H]/.test(e); },
3019 "I - L" : function(e, n, f, i, $r, c, data) { return /^[I-L]/.test(e); },
3020 "M - P" : function(e, n, f, i, $r, c, data) { return /^[M-P]/.test(e); },
3021 "Q - T" : function(e, n, f, i, $r, c, data) { return /^[Q-T]/.test(e); },
3022 "U - X" : function(e, n, f, i, $r, c, data) { return /^[U-X]/.test(e); },
3023 "Y - Z" : function(e, n, f, i, $r, c, data) { return /^[Y-Z]/.test(e); }
3024 }
3025 }
3026 }
3027 });
3028 });</pre>
3029 <h4>Comparison example</h4>
3030 <pre class="prettyprint lang-js">$(function() {
3031 $("table").tablesorter({
3032 widgets: ["filter"],
3033 widgetOptions: {
3034 // function variables:
3035 // e = exact text from cell
3036 // n = normalized value returned by the column parser
3037 // f = search filter input value
3038 // i = column index
3039 // $r = jQuery element of current row
3040 // c = table.config
3041 // data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
3042 filter_functions: {
3043 // Add these options to the select dropdown (numerical comparison example)
3044 // Note that only the normalized (n) value will contain numerical data
3045 // If you use the exact text, you'll need to parse it (parseFloat or parseInt)
3046 4 : {
3047 "&lt; $10" : function(e, n, f, i, $r, c, data) { return n &lt; 10; },
3048 "$10 - $100" : function(e, n, f, i, $r, c, data) { return n &gt;= 10 && n &lt;=100; },
3049 "&gt; $100" : function(e, n, f, i, $r, c, data) { return n &gt; 100; }
3050 }
3051 }
3052 }
3053 });
3054 });</pre>
3055 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>
3056 </li>
3057 <li>
3058 Make a custom filter for the column.
3059 <pre class="prettyprint lang-js">$(function() {
3060 $("table").tablesorter({
3061 widgets: ["filter"],
3062 widgetOptions: {
3063 // function variables:
3064 // e = exact text from cell
3065 // n = normalized value returned by the column parser
3066 // f = search filter input value
3067 // i = column index
3068 // $r = jQuery element of current row
3069 // c = table.config
3070 // data = combined filter data - see filter widget "custom searches" demo, look under "How to add Custom filter types"
3071 filter_functions: {
3072 // Exact match only
3073 1 : function(e, n, f, i, $r, c, data) {
3074 return e === f;
3075 }
3076 }
3077 }
3078 });
3079 });</pre>
3080 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>
3081 </li>
3082 </ul>
3083 </div>
3084 </td>
3085 <td><a href="example-widget-filter-custom.html">Example</a></td>
3086 </tr>
3087
3088 <tr id="widget-filter-hideempty">
3089 <td><a href="#" class="permalink">filter_hideEmpty</a></td>
3090 <td>Boolean</td>
3091 <td>true</td>
3092 <td>
3093 Filter widget: Set this option to <code>false</code> to always show the filter row; by default, the filter row is completely hidden when no rows exist within the tbody (<span class="version">v2.15</span>).
3094 <div class="collapsible">
3095 <br>
3096 Use the <a href="#widget-filter-hideempty"><code>filter_hideEmpty</code></a> option as follows:
3097 <pre class="prettyprint lang-js">$(function() {
3098 $("table").tablesorter({
3099 widgets: ["filter"],
3100 widgetOptions : {
3101 filter_hideEmpty : false
3102 }
3103 });
3104 });</pre></div>
3105 </td>
3106 <td></td>
3107 </tr>
3108
3109 <tr id="widget-filter-hidefilters">
3110 <td><a href="#" class="permalink">filter_hideFilters</a></td>
3111 <td>Boolean, or Function</td>
3112 <td>false</td>
3113 <td>
3114 Filter widget: Set this option to <code>true</code> to hide the filter row initially. The row is revealed by hovering over the visible portion of the filter row or by giving any filter input/select focus (tab key) (v2.4; <span class="version updated">v2.26.6</span>).
3115 <div class="collapsible">
3116 <br>
3117 Use the <a href="#widget-filter-hidefilters"><code>filter_hideFilters</code></a> option as follows:
3118 <pre class="prettyprint lang-js">$(function() {
3119 $("table").tablesorter({
3120 widgets: ["filter"],
3121 widgetOptions : {
3122 filter_hideFilters : true
3123 }
3124 });
3125 });</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.
3126 In <span class="version updated">v2.26.6</span>, this setting can also contain a function.
3127 <ul>
3128 <li>When this function returns a boolean value, it signifies whether the filter row should or should not be hidden (see the details in <a href="https://github.com/Mottie/tablesorter/issues/477#issuecomment-229352896">this issue</a>.</li>
3129 <li>If this function does not return a boolean value, the value of the filters are checked and if no search queries are found, the filter row will be hidden.</li>
3130 </ul>
3131 Example of function setting:
3132 <pre class="prettyprint lang-js">$(function() {
3133 $("table").tablesorter({
3134 widgets: ["filter"],
3135 widgetOptions : {
3136 filter_hideFilters : function(config) {
3137 // get an array of filter queries (don't use the value from
3138 // `config.lastSearch` because this code will modify it;
3139 // unless you extend it)
3140 var search = $.tablesorter.getFilters(config.$table);
3141 // ignore any query is column 2 (zero-based index)
3142 search.splice(2,1);
3143 // return true to hide the filter row, false to show it
3144 return search.join("") === "";
3145 }
3146 }
3147 });
3148 });</pre></div>
3149 </td>
3150 <td><a href="example-widget-filter.html">Example</a></td>
3151 </tr>
3152
3153 <tr id="widget-filter-ignorecase">
3154 <td><a href="#" class="permalink">filter_ignoreCase</a></td>
3155 <td>Boolean</td>
3156 <td>true</td>
3157 <td>
3158 Filter widget: Set this option to <code>false</code> to make the column content search case-sensitive, so typing in &quot;a&quot; will not find &quot;Albert&quot;. (v2.3.4)
3159 <div class="collapsible">
3160 <br>
3161 Use the <a href="#widget-filter-ignorecase"><code>filter_ignoreCase</code></a> option as follows:
3162 <pre class="prettyprint lang-js">$(function() {
3163 $("table").tablesorter({
3164 widgets: ["filter"],
3165 widgetOptions : {
3166 filter_ignoreCase : false
3167 }
3168 });
3169 });</pre></div>
3170 </td>
3171 <td><a href="example-widget-filter.html">Example</a></td>
3172 </tr>
3173
3174 <tr id="widget-filter-livesearch">
3175 <td><a href="#" class="permalink">filter_liveSearch</a></td>
3176 <td>Boolean, Number or Object</td>
3177 <td>true</td>
3178 <td>
3179 Filter widget: If <code>true</code>, a search of the column content will occur as the user types, with the delay set in the <code>filter_searchDelay</code> option (v2.9; <span class="version updated">v2.27.3</span>).
3180 <div class="collapsible">
3181 <br>
3182 This option, when <code>false</code> allows you to disable the live search behavior, so that a filter is only applied when the user presses <kbd>Enter</kbd> (or uses <kbd>Esc</kbd> to clear and cancel the search).<br>
3183 <br>
3184 If this option is set to a number, e.g. <code>4</code>, a search of the column content will not initiate until this minimum number of characters are entered into the input.
3185 <p>In <span class="version">v2.27.3</span>, this option can be set as an object containing specific column zero-based indexes, or class names. For undefined columns, include a <code>"fallback"</code> value otherwise undefined columns will be set as <code>false</code>.</p>
3186 <pre class="prettyprint lang-js">$(function() {
3187 $("table").tablesorter({
3188 widgets: ["filter"],
3189 widgetOptions : {
3190 filter_liveSearch : {
3191 // when false, the user must press enter to blur the input to trigger the search
3192 3 : false,
3193 // the query will initiate when 5 or more characters are entered into the filter
3194 4 : 5,
3195 // no live search on the last three columns (using a header class name)
3196 '.last-3-columns' : false,
3197 // for columns that aren't defined; this will set the fallback value
3198 // otherwise the fallback defaults to false.
3199 'fallback' : true
3200 }
3201 }
3202 });
3203 });</pre>
3204 </div>
3205 </td>
3206 <td></td>
3207 </tr>
3208
3209 <tr id="widget-filter-matchtype">
3210 <td><a href="#" class="permalink">filter_matchType</a></td>
3211 <td>Object</td>
3212 <td>{ 'input': 'exact', 'select': 'exact' }</td>
3213 <td>
3214 Filter widget: This option sets the global setting that applied to either input or select filters (<span class="version">v2.25.5</span>)
3215 <div class="collapsible">
3216 <p>A basic input filter will match the filter query until a "and" and "or" type search is performed.</p>
3217 <p>By default, select filters and "and" and "or type searchs will look for an exact match, and to override this behavior you *had* to add a "filter-match" class to the columns to allow partial matches.</p>
3218 <p>This option allows you to set a global "match" setting and save you the trouble of adding a bunch of classes.</p>
3219 <p>There are only two options: "exact" and "match"; and it defaults to "exact" if anything else is entered.</p>
3220 In the demo, try searching for <code>super or man</code> in the first column.
3221 </div>
3222 </td>
3223 <td><a href="example-widget-formatter.html">Example</a></td>
3224 </tr>
3225
3226 <tr id="widget-filter-onlyAvail">
3227 <td><a href="#" class="permalink">filter_onlyAvail</a></td>
3228 <td>String</td>
3229 <td>&quot;filter-onlyAvail&quot;</td>
3230 <td>
3231 Filter widget: If a header contains a select dropdown and this class name, only the available (visible) options in the column will show (<span class="version">v2.10.1</span>; <span class="version updated">v2.17.6</span>).
3232 <div class="collapsible">
3233 <br>
3234 In <span class="version">v2.17.6</span>, columns with the only available class name set, that <em>are not</em> currently being filtered will only show the available options. Conversely, the column(s) with a selected option will show all options.<br>
3235 <br>
3236 This option is useful after one or more columns have been filtered, then the column select filter with this class applied will only show the contents of the column within the dropdown that are currently visible. See the <a href="example-widget-filter-custom.html">custom filter widget</a> demo &quot;Discount&quot; column for an example (sort the &quot;First Name&quot; column first).<br>
3237 <br>
3238 <span class="label label-warning">Caution:</span> The main issue with this functionality is with keyboard accessibility. If the keyboard is used to select an option, only the first and default options will be available for chosing. The only way to select other options is with the mouse.
3239 </div>
3240 </td>
3241 <td><a href="example-widget-filter-custom.html">Example</a></td>
3242 </tr>
3243
3244 <tr id="widget-filter-placeholder">
3245 <td><a href="#" class="permalink">filter_placeholder</a></td>
3246 <td>object</td>
3247 <td>{ search : '', select : '' }</td>
3248 <td>
3249 Filter widget: Set global filter input placeholder text for search inputs and selects (<span class="version">v2.16</span>).
3250 <div class="collapsible">
3251 <br>
3252 Any search type input added to the filter row will automatically get a placeholder attribute added, the source of this placeholder text is from the following sources, in order of priority:
3253 <ul>
3254 <li>Header cell data (<code>table.config.$headers.eq(0).data('placeholder', 'search for...');</code></li>
3255 <li>Header cell data-attribute (<code>&lt;th data-placeholder="Find Rank..."&gt;Rank&lt;/th&gt;</code>)</li>
3256 <li>Global <code>filter_placeholder.search</code> setting.</li>
3257 </ul>
3258 The <code>filter_placeholder.select</code> setting adds the text to the first select option (default option to show all rows).<br>
3259 <br>
3260 <span class="label label-info">Note:</span> The <code>widget-filter-formatter-jui.js</code> jQuery UI Datepicker Range Selector creates two inputs, so this option then includes two additional settings:<br>
3261 <br>
3262 <pre class="prettyprint lang-js">filter_placeholder : {
3263 search : '',
3264 select : '',
3265 from : '', // datepicker range "from" placeholder
3266 to : '' // datepicker range "to" placeholder
3267 }
3268 </pre><span class="label label-info">Note:</span> The browser must support the <a class="external" href="http://caniuse.com/#feat=input-placeholder">placeholder attribute</a> before it will be visible.
3269 </div>
3270 </td>
3271 <td><a href="example-widget-filter-formatter-1.html">Example</a></td>
3272 </tr>
3273
3274 <tr id="widget-filter-reset">
3275 <td><a href="#" class="permalink">filter_reset</a></td>
3276 <td>String, jQuery object</td>
3277 <td>null</td>
3278 <td>
3279 Filter widget: jQuery selector string of an element used to reset the filters (v2.4; <span class="version updated">v2.16</span>).
3280 <div class="collapsible">
3281 <p>
3282 When this option points to a reset element using a jQuery selector string, it is bound using <a class="external" href="http://api.jquery.com/on/#direct-and-delegated-events">event delegation</a>. So if any additional reset elements, with the same class name, are added to the page dynamically, they will be associated with the same table.<br>
3283 <br>
3284 For example, add this button (<code>&lt;button class="reset"&gt;Reset&lt;/button&gt;</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):
3285 </p>
3286 Use the <a href="#widget-filter-reset"><code>filter_reset</code></a> option as follows:
3287 <pre class="prettyprint lang-js">$(function() {
3288 $("table").tablesorter({
3289 widgets: ["filter"],
3290 widgetOptions : {
3291 filter_reset : '.reset'
3292 }
3293 });
3294 });</pre>
3295 If this option contains a jQuery object (<span class="version">v2.16</span>), clicking on any of the elements within that jQuery object will trigger a filter reset. If any additional elements with the same selector are added to the page, they will not be dynamically functional.<br>
3296 <br>
3297 If either of these methods do not work as desired, simply trigger a <a href="#filterreset"><code>filterReset</code> event</a> on the table.
3298 </div>
3299 </td>
3300 <td><a href="example-widget-filter-custom.html">Example</a></td>
3301 </tr>
3302
3303 <tr id="widget-filter-resetonesc">
3304 <td><a href="#" class="permalink">filter_resetOnEsc</a></td>
3305 <td>Boolean</td>
3306 <td>true</td>
3307 <td>
3308 Filter widget: when <code>true</code>, normalize pressing escape to clear filter input across browsers (<span class="version">v2.25.2</span>).
3309 <div class="collapsible">
3310 <p>Webkit browsers automatically clear the filter search input when pressing escape, but IE and Firefox do not. Setting this option to <code>true</code>, clears the filter input when the user presses escape.</p>
3311 When this option is set to <code>false</code>, pressing escape inside the search field is ignored.
3312 </div>
3313 </td>
3314 <td></td>
3315 </tr>
3316
3317 <tr id="widget-filter-savefilters">
3318 <td><a href="#" class="permalink">filter_saveFilters</a></td>
3319 <td>Boolean</td>
3320 <td>false</td>
3321 <td>
3322 Filter widget: If the storage utility is available (included with <code>jquery.tablesorter.widgets.js</code> file, the last applied filter is saved to storage (<span class="version">v2.14</span>).
3323 <div class="collapsible">
3324 <br>
3325 Filters saved to local storage (or cookies) will override any default filters within the header data-attribute (set by the <a href="#widget-filter-defaultattrib"><code>filter_defaultAttrib</code> option</a>) and be available to the pager before any ajax calls are made.<br>
3326 <br>
3327 To bypass this behavior, clear out the saved filters as follows:
3328 <pre class="prettyprint lang-js">$.tablesorter.storage( $('table'), 'tablesorter-filters', '' );</pre>
3329 </div>
3330 </td>
3331 <td><a href="example-widget-filter-custom.html">Example</a></td>
3332 </tr>
3333
3334 <tr id="widget-filter-searchdelay">
3335 <td><a href="#" class="permalink">filter_searchDelay</a></td>
3336 <td>Numeric</td>
3337 <td>300</td>
3338 <td>
3339 Filter widget: Set this option to the number of milliseconds to delay the search. (v2.3.4).
3340 <div class="collapsible">
3341 <br>
3342 Use the <a href="#widget-filter-searchdelay"><code>filter_searchDelay</code></a> option as follows:
3343 <pre class="prettyprint lang-js">$(function() {
3344 $("table").tablesorter({
3345 widgets: ["filter"],
3346 widgetOptions : {
3347 filter_searchDelay : 500
3348 }
3349 });
3350 });</pre>
3351
3352 If you want to want to initialize the filter without user input, target any one of the filters and trigger a "search".
3353
3354 <pre class="prettyprint lang-js">// target the first filter input
3355 // this method will begin the search after the searchDelay time
3356 $('input.tablesorter-filter:eq(0)').trigger('search');
3357
3358 // this method will begin the search immediately
3359 $('input.tablesorter-filter:eq(0)').trigger('search', false);</pre>
3360
3361 In tablesorter v2.4+, the trigger can be applied directly to the table:
3362 <pre class="prettyprint lang-js">// refresh the widget filter; no delay
3363 $('table').trigger('search', false);</pre></div>
3364 </td>
3365 <td></td>
3366 </tr>
3367
3368 <tr id="widget-filter-searchfiltered">
3369 <td><a href="#" class="permalink">filter_searchFiltered</a></td>
3370 <td>Boolean</td>
3371 <td>true</td>
3372 <td>
3373 Filter widget: Set this option to allow searching through already filtered rows (in special conditions); this will speed up searching in large tables (<span class="version">v2.17.4</span>).
3374 <div class="collapsible">
3375 <br>
3376 To better explain this, lets do it by example. Lets say you have a column of color names and you enter "light" and results like "light blue" and "light grey" show up.<br>
3377 <br>
3378 When you press the space bar, a space is added, and instead of searching though all of the colors again, the filter widget only searches through the already filtered results that started with "light". This can substantially speed up searching, especially in large tables.<br>
3379 <br>
3380 But, there are some special circumstances which would make this method return incorrect results. So, this option was added to allow you to disable this feature in case one of these following conditions doesn't cover your need; but still, please report any issues!<br>
3381 <br>
3382 The search through filtered results <em>only occurs</em> if the following conditions are met:
3383 <ul>
3384 <li>The last search (for all columns) was not completely empty - all rows will be searched anyway.</li>
3385 <li>If there were no changes to the search from the beginning of the search string (changing the above search to "bright" will force a new search of all rows).</li>
3386 <li>If the search does not contain a logical or (<code> or </code> or <code>|</code>), or a range delimiter (<code> - </code> or <code> to </code>) within the search query.</li>
3387 <li>If the search is not looking for an exact match (<code>&quot;</code> or <code>=</code>) or a logical not search (<code>!</code>).</li>
3388 <li>Or, if the search is using a select dropdown without a "filter-match" class name (looking for an exact match).</li>
3389 <li>If the search does not contain an operator greater than or equal to a negative number (<code>&gt;=-10</code>) or less than or equal to a positive number (<code>&lt;=10</code>).</li>
3390 <li>And lastly, only search filtered rows if all rows are not hidden.</li>
3391 </ul>
3392 If the <code>debug</code> option is set to <code>true</code>, then a message will appear while filtering stating the specific number of rows, or "all" rows, that are being searched.<br>
3393 <br>
3394 Use the <a href="#widget-filter-searchfiltered"><code>filter_searchFiltered</code></a> option as follows:
3395 <pre class="prettyprint lang-js">$(function() {
3396 $("table").tablesorter({
3397 widgets: ["filter"],
3398 widgetOptions : {
3399 filter_searchFiltered : false
3400 }
3401 });
3402 });</pre></div>
3403 </td>
3404 <td><a href="example-widget-filter-custom.html#custom_filter_function">Example</a></td>
3405 </tr>
3406
3407 <tr id="widget-filter-selectsource">
3408 <td><a href="#" class="permalink">filter_selectSource</a></td>
3409 <td>Function</td>
3410 <td>null</td>
3411 <td>
3412 Filter widget: Include a function to return an array of values to be added to the column filter select (<span class="version">v2.16.0</span>; <span class="version updated">v2.28.12</span>).
3413 <div class="collapsible">
3414 <br>
3415 In <span class="version updated">v2.24.4</span>, this option will now accept an array of objects which can contain extra information for each option. Here is an example modified from the <a href="example-widget-filter-selectmenu.html">filter selectmenu demo</a>:
3416 <pre class="prettyprint lang-js">filter_selectSource : {
3417 0 : [
3418 { value : '/\\.js$/', 'data-class' : 'ui-icon-script', text : 'javascript' },
3419 { value : '/\\.(jpg|png|gif)$/', 'data-class' : 'ui-icon-image', text : 'Image' },
3420 // plain strings are also acceptable - the string is added to both the text & value attribute
3421 'foobar',
3422 { value : '.css', 'data-class' : 'ui-icon-note', text : 'CSS' },
3423 { value : '.html', 'data-class' : 'ui-icon-document', text : 'HTML page' },
3424 { value : '/\\.(json|txt|md)$/', 'data-class' : 'ui-icon-help', text : 'Misc' },
3425 ]
3426 }</pre>
3427 <ul>
3428 <li>Each object entry <em>must</em> include a <code>text</code> property, or it will get ignored.</li>
3429 <li>If no <code>value</code> property is set, the option value will be equal to the <code>text</code> (IE requires a value defined for every option).</li>
3430 <li>Plain strings are still allowed within the array. If included, both the option text &amp; value attribute will contain the string.</li>
3431 <li><span class="label warning">*NOTE*</span> when returning an array containing objects, the options will not be reduced to obtain unique selections.</li>
3432 <li><span class="label warning">*NOTE*</span> because this example is providing a fixed select option source, it can not support "filter-onlyAvail" (only show available options after filtering).</li>
3433 </ul>
3434
3435 <p>
3436 In <span class="version updated">v2.28.12</span>, return <code>null</code> from a <code>filter_selectSource</code> function to prevent updates to the select options. Useful if you are updating the select options from outside of tablesorter.
3437 <pre class="prettyprint lang-js">filter_selectSource : {
3438 ".filter-select" : function() { return null; }
3439 }</pre>
3440 </p>
3441 <p>
3442 In <span class="version updated">v2.27.7</span>, an option to have a descending sort applied to this data can be done by adding a <code>"filter-select-sort-desc"</code> to the header cell. Adding a <code>"filter-select-nosort"</code> class name to a header to prevent sorting has been available since v2.16.3.
3443 </p>
3444 <p>
3445 In <span class="version updated">v2.21.5</span>, this option will now override the <code>filter_function</code> options (<em>so you need to add them back!</em>), allowing the addition of custom select options and still maintain basic filtering action - see <a href="http://jsfiddle.net/Mottie/856bzzeL/117/">this demo</a> (<a class="external" href="http://stackoverflow.com/a/29506523/145346">ref</a>).
3446 </p>
3447 In <span class="version updated">v2.17.0</span>, the <code>filter_selectSource</code> column can also be referenced by using a jQuery selector (e.g. class name or ID) that points to a table <em>header</em> cell.<br>
3448 <pre class="prettyprint lang-js">filter_selectSource : {
3449 ".model-number" : [ "abc", "def", "ghi", "xyz" ]
3450 }</pre>
3451 <span class="label label-warning">Warning</span> What <em>won't work</em> is if you try to target the header using a filtering selector that uses an index, e.g. <code>&quot;th:eq()&quot;</code>, <code>&quot;:gt()&quot;</code>, <code>&quot;:lt()&quot;</code>, <code>&quot;:first&quot;</code>, <code>&quot;:last&quot;</code>, <code>&quot;:even&quot;</code> or <code>&quot;:odd&quot;</code>, <code>&quot;:first-child&quot;</code>, <code>&quot;:last-child&quot;</code>, <code>&quot;:nth-child()&quot;</code>, <code>&quot;:nth-last-child()&quot;</code>, etc.<br>
3452 <br>
3453 A column will have a filter select dropdown when a "filter-select" class name is added to the header cell, or if the <a href="#widget-filter-functions"><code>filter_functions</code></a> column value is set to <code>true</code><br>
3454 <br>
3455 This option allows using an alternate source, or customizing options of the filter select dropdown. This option can be set as follows:
3456 <ul>
3457 <li><code>null</code> - this value will set the default behavior and return all table cell values from the current column.</li>
3458 <li>An overall function - when this option is a function, it will be used for all filter selects in the table.
3459 <pre class="prettyprint lang-js">$(function() {
3460 $("table").tablesorter({
3461 widgets: ["filter"],
3462 widgetOptions : {
3463 filter_selectSource : function(table, column, onlyAvail) {
3464 // get an array of all table cell contents for a table column
3465 var array = $.tablesorter.filter.getOptions(table, column, onlyAvail);
3466 // manipulate the array as desired, then return it
3467 return array;
3468 }
3469 }
3470 });
3471 });</pre>
3472 </li>
3473 <li>An object containing column keys set with a function - when the option is set in this manner, a function can be applied to a specific column.
3474 <p>This example was updated in <span class="version">v2.23.4</span> to use the <code>buildSelect</code> function directly (<a href="https://github.com/Mottie/tablesorter/issues/1010">ref</a>)</p>
3475 <pre class="prettyprint lang-js">$(function() {
3476 $("table").tablesorter({
3477 widgets: ["filter"],
3478 widgetOptions : {
3479 filter_selectSource : {
3480 0 : function(table, column, onlyAvail) {
3481 // call ajax after tablesorter has initialized; this prevents
3482 // multiple ajax calls during initialization
3483 if (table.hasInitialized) {
3484 $.getJSON('ajax/options.json', function(data) {
3485 // return false if there is a problem and the select
3486 // will display the original defaults
3487 var result = data.hasOwnProperty('options') ? data.options : false;
3488 // if not already done on the server-side & you want to sort & remove duplicates
3489 // from the results, use the processOptions function (added 2.23.4)
3490 result = $.tablesorter.filter.processOptions( table, column, result );
3491 // call the buildSelect function; pass `true` to replace the contents of the select
3492 $.tablesorter.filter.buildSelect( table, column, result, true, onlyAvail );
3493 });
3494 }
3495 return false;
3496 }
3497 }
3498 }
3499 });
3500 });</pre>
3501 </li>
3502 </ul>
3503 The function uses the following parameters:
3504 <ul>
3505 <li><code>table</code> - table DOM element</li>
3506 <li><code>column</code> - zero-based index of the column with a filter select</li>
3507 <li><code>onlyAvail</code> - boolean indicating if the returned options should only be from available (non-filtered) rows.</li>
3508 </ul>
3509 <span class="label label-info">Important</span> Return an array of values which will be added to the filter select dropdown. This array will automatically be stripped of any duplicate values and sorted alphanumerically before being added to the select. If for some reason the custom <code>filter_selectSource</code> function does not obtain the desired array of values, return <code>false</code> and the original method of obtaining column cell content will be used.
3510 </div>
3511 </td>
3512 <td><a href="example-widget-filter-formatter-select2.html">1</a> <a href="example-widget-filter-selectmenu.html">2</a></td>
3513 </tr>
3514
3515 <tr id="widget-filter-selectsource-separator">
3516 <td><a href="#" class="permalink">filter_selectSourceSeparator</a></td>
3517 <td>String</td>
3518 <td>'|'</td>
3519 <td>
3520 Filter widget: Set this option to be any separator (<span class="version">v2.17.6</span>) that is to be used within the <code>filter_selectSource</code> returned array.
3521 <div class="collapsible">
3522 <br>
3523 Use the <a href="#widget-filter-selectsource-separator"><code>filter_selectSourceSeparator</code></a> option as follows:
3524 <pre class="prettyprint lang-js">$(function() {
3525 $("table").tablesorter({
3526 widgets: ["filter"],
3527 widgetOptions : {
3528 filter_selectSource : {
3529 0 : [ 'en|English', 'fr|French', 'de|German' ]
3530 },
3531 // filter_selectSource array text left of the separator is added to the option value, right into the option text
3532 filter_selectSourceSeparator : '|'
3533 }
3534 });
3535 });</pre>Results in this HTML:
3536 <pre class="prettyprint lang-html">&lt;select&gt;
3537 &lt;option value=&quot;&quot;&gt;&lt;/option&gt;
3538 &lt;option value=&quot;en&quot;&gt;English&lt;/option&gt;
3539 &lt;option value=&quot;fr&quot;&gt;French&lt;/option&gt;
3540 &lt;option value=&quot;de&quot;&gt;German&lt;/option&gt;
3541 &lt;/select&gt;</pre>This also works for the <code>filter_functions</code>
3542 <pre class="prettyprint lang-js">$(function() {
3543 $("table").tablesorter({
3544 widgets: ["filter"],
3545 widgetOptions: {
3546 filter_functions: {
3547 // Add these options to the select dropdown (regex example)
3548 1 : {
3549 "&lt;10|Less than 10" : function(e, n, f, i, $r, c, data) { return n &lt; 10; },
3550 "10 - 100|Between 10 & 100" : function(e, n, f, i, $r, c, data) { return n &gt;= 10 && n &lt;=100; },
3551 "&gt;100|Greater than 100" : function(e, n, f, i, $r, c, data) { return n &gt; 100; }
3552 }
3553 },
3554 // filter_selectSource array text left of the separator is added to the option value, right into the option text
3555 filter_selectSourceSeparator : '|'
3556 }
3557 });
3558 });</pre>
3559 Results in this HTML (this adds a <code>data-function-name</code> attribute to keep a reference to the associated <code>filter_functions</code>.
3560 <pre class="prettyprint lang-html">&lt;select&gt;
3561 &lt;option value=&quot;&quot;&gt;&lt;/option&gt;
3562 &lt;option data-function-name="&amp;lt;10|Less than 10" value=&quot;&amp;lt;10&quot;&gt;Less than 10&lt;/option&gt;
3563 &lt;option data-function-name="10 - 100|Between 10 &amp;amp; 100" value=&quot;10 - 100&quot;&gt;Between 10 & 100&lt;/option&gt;
3564 &lt;option data-function-name="&amp;gt;100|Greater than 100" value=&quot;&amp;gt;100&quot;&gt;Greater than 100&lt;/option&gt;
3565 &lt;/select&gt;</pre>
3566 </div>
3567 </td>
3568 <td></td>
3569 </tr>
3570
3571 <tr id="widget-filter-serversidefiltering">
3572 <td><a href="#" class="permalink">filter_serversideFiltering</a></td>
3573 <td>Boolean</td>
3574 <td>false</td>
3575 <td>
3576 Filter widget: Set this option to <code>true</code> if filtering is performed on the server-side (v2.5.3).
3577 <div class="collapsible">
3578 <br>
3579 Use the <a href="#widget-filter-serversidefiltering"><code>filter_serversideFiltering</code></a> option as follows:
3580 <pre class="prettyprint lang-js">$(function() {
3581 $("table").tablesorter({
3582 widgets: ["filter"],
3583 widgetOptions : {
3584 filter_serversideFiltering : true
3585 }
3586 });
3587 });</pre></div>
3588 </td>
3589 <td></td>
3590 </tr>
3591
3592 <tr id="widget-filter-startswith">
3593 <td><a href="#" class="permalink">filter_startsWith</a></td>
3594 <td>Boolean</td>
3595 <td>false</td>
3596 <td>
3597 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 &quot;a&quot; will find &quot;albert&quot; but not &quot;frank&quot;, both have a's. (v2.1).
3598 <div class="collapsible">
3599 <br>
3600 Use the <a href="#widget-filter-startswith"><code>filter_startsWith</code></a> option as follows:
3601 <pre class="prettyprint lang-js">$(function() {
3602 $("table").tablesorter({
3603 widgets: ["filter"],
3604 widgetOptions : {
3605 filter_startsWith : true
3606 }
3607 });
3608 });</pre></div>
3609 </td>
3610 <td><a href="example-widget-filter.html">Example</a></td>
3611 </tr>
3612
3613 <tr id="widget-filter-useParsedData">
3614 <td><a href="#" class="permalink">filter_useParsedData</a></td>
3615 <td>Boolean</td>
3616 <td>false</td>
3617 <td>
3618 Filter widget: If <code>true</code>, ALL filter searches will only use parsed data (v2.4).
3619 <div class="collapsible">
3620 <br>
3621 Use the <a href="#widget-filter-useParsedData"><code>filter_useParsedData</code></a> option as follows:
3622 <pre class="prettyprint lang-js">$(function() {
3623 $("table").tablesorter({
3624 widgets: ["filter"],
3625 widgetOptions : {
3626 filter_useParsedData : false
3627 }
3628 });
3629 });</pre>
3630 <ul>
3631 <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:
3632 <ul>
3633 <li>jQuery data <code>data-filter=&quot;parsed&quot;</code>.</li>
3634 <li>metadata <code>class=&quot;{ filter: 'parsed'}&quot;</code>. This requires the metadata plugin.</li>
3635 <li>headers option <code>headers : { 0 : { filter : 'parsed' } }</code>.</li>
3636 <li>header class name <code>class=&quot;filter-parsed&quot;</code>.</li>
3637 </ul>
3638 </li>
3639 <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>
3640 </ul>
3641 </div>
3642 </td>
3643 <td></td>
3644 </tr>
3645
3646 <tr id="widget-filter-defaultattrib">
3647 <td><a href="#" class="permalink">filter_defaultAttrib</a></td>
3648 <td>String</td>
3649 <td>&quot;data-value&quot;</td>
3650 <td>
3651 Filter widget: This option contains the name of the data-attribute which contains the default (starting) filter value (<span class="version">v2.10.8</span>).
3652 <div class="collapsible">
3653 <br>
3654 Use the <a href="#widget-filter-defaultattrib"><code>filter_defaultAttrib</code></a> option as follows:
3655 <pre class="prettyprint lang-js">$(function() {
3656 $("table").tablesorter({
3657 widgets: ["filter"],
3658 widgetOptions : {
3659 filter_defaultAttrib : 'data-value'
3660 }
3661 });
3662 });</pre>Then add the default filter value to the table header as follows:<pre class="prettyprint lang-html">&lt;th data-value=&quot;&lt;30&quot;&gt;Age&lt;/th&gt;</pre></div>
3663 </td>
3664 <td><a href="example-widget-filter-custom.html">Example</a></td>
3665 </tr>
3666
3667 <tr id="widget-sticky-headers">
3668 <td><a href="#" class="permalink">stickyHeaders</a></td>
3669 <td>String</td>
3670 <td>&quot;&quot;</td>
3671 <td>Sticky Headers widget: This additional CSS class applied to the sticky header row (<span class="version updated">v2.11</span>).
3672 <div class="collapsible"><br>
3673 Changed to empty string in v2.11, as the <code>&quot;tablesorter-stickyHeader&quot;</code> class will always be added to the sticky header row; this option now contains any additional class names to add.
3674 <p>Previously, this option contained the class name to be applied to the sticky header row (tr) (v2.1).</p>
3675 Use the <a href="#widget-sticky-headers"><code>&quot;stickyHeaders&quot;</code></a> option to add an extra css class name as follows:
3676 <pre class="prettyprint lang-js">$(function() {
3677 $("table").tablesorter({
3678 widgets: ["stickyHeaders"],
3679 widgetOptions : {
3680 // css class name applied to the sticky header
3681 stickyHeaders : "tablesorter-stickyHeader"
3682 }
3683 });
3684 });</pre></div>
3685 </td>
3686 <td><a href="example-widget-sticky-header.html">Example</a></td>
3687 </tr>
3688
3689 <tr id="widget-sticky-headers-cloneid">
3690 <td><a href="#" class="permalink">stickyHeaders_cloneId</a></td>
3691 <td>String</td>
3692 <td>&quot;-sticky&quot;</td>
3693 <td>
3694 Sticky Headers widget: If the table has an ID defined, the suffix from this option will be added to the ID in the cloned sticky table (<span class="version">v2.9</span>).
3695 <div class="collapsible">
3696 <br>
3697 So if your table ID is <code>&quot;gummy&quot;</code>, then the cloned sticky table id becomes <code>&quot;gummy-sticky&quot;</code><br>
3698 <br>
3699 Use the <a href="#widget-sticky-headers-cloneid"><code>&quot;stickyHeaders_cloneId&quot;</code></a> option to change the cloned table id as follows:
3700 <pre class="prettyprint lang-js">$(function() {
3701 $("table").tablesorter({
3702 widgets: ["stickyHeaders"],
3703 widgetOptions : {
3704 // cloned table id suffix
3705 stickyHeaders_cloneId : "-clone"
3706 }
3707 });
3708 });</pre></div>
3709 </td>
3710 <td></td>
3711 </tr>
3712
3713 <tr id="widget-sticky-headers-include-caption">
3714 <td><a href="#" class="permalink">stickyHeaders_includeCaption</a></td>
3715 <td>Boolean</td>
3716 <td>true</td>
3717 <td>
3718 Sticky Headers widget: If this option is <code>false</code> and a caption exists, it will not be included in the sticky header (<span class="version">v2.10.8</span>).
3719 <div class="collapsible">
3720 <br>
3721 Use the <a href="#widget-sticky-headers-include-caption"><code>stickyHeaders_includeCaption</code></a> option as follows:
3722 <pre class="prettyprint lang-js">$(function() {
3723 $("table").tablesorter({
3724 widgets: ["stickyHeaders"],
3725 widgetOptions : {
3726 // cloned table id suffix
3727 stickyHeaders_includeCaption : false
3728 }
3729 });
3730 });</pre></div>
3731 </td>
3732 <td><a href="example-widget-sticky-header.html">Example</a></td>
3733 </tr>
3734
3735 <tr id="widget-sticky-headers-appendto">
3736 <td><a href="#" class="permalink">stickyHeaders_appendTo</a></td>
3737 <td>String, jQuery Object</td>
3738 <td>null</td>
3739 <td>
3740 Sticky Headers widget: jQuery selector or object to physically attach the sticky headers (<span class="version">v2.27.0</span>).
3741 <div class="collapsible">
3742 <p>
3743 <span class="label label-warning">Note</span> Appending the sticky headers to an element that does not have the same dimensions (width) as the table wrapper will produce a sticky header that does not match the table size!
3744 </p>
3745 Use the <a href="#widget-sticky-headers-appendto"><code>stickyHeaders_appendTo</code></a> option as follows:<br>
3746 <pre class="prettyprint lang-js">$(function() {
3747 $("table").tablesorter({
3748 widgets: ["stickyHeaders"],
3749 widgetOptions : {
3750 // Where to attach the stickyHeaders
3751 stickyHeaders_appendTo : '.wrapper' // $('.wrapper') jQuery object can also be used
3752 }
3753 });
3754 });</pre></div>
3755 </td>
3756 <td></td>
3757 </tr>
3758
3759 <tr id="widget-sticky-headers-attachto">
3760 <td><a href="#" class="permalink">stickyHeaders_attachTo</a></td>
3761 <td>String, jQuery Object</td>
3762 <td>null</td>
3763 <td>
3764 Sticky Headers widget: points to the table wrapper to stick the headers to while scrolling. Use this option to point to their needs (<span class="version">v2.14.4</span>).
3765 <div class="collapsible">
3766 <br>
3767 Use the <a href="#widget-sticky-headers-attachto"><code>stickyHeaders_attachTo</code></a> option as follows:<br>
3768 <pre class="prettyprint lang-js">$(function() {
3769 $("table").tablesorter({
3770 widgets: ["stickyHeaders"],
3771 widgetOptions : {
3772 // Where to attach the stickyHeaders
3773 stickyHeaders_attachTo : '.wrapper' // $('.wrapper') jQuery object can also be used
3774 }
3775 });
3776 });</pre></div>
3777 </td>
3778 <td><a href="example-widget-sticky-header.html">Example</a></td>
3779 </tr>
3780
3781 <tr id="widget-sticky-headers-xscroll">
3782 <td><a href="#" class="permalink">stickyHeaders_xScroll</a></td>
3783 <td>String, jQuery Object</td>
3784 <td>null</td>
3785 <td>
3786 Sticky Headers widget: points to the element in which to monitor for horizontal scrolling (<span class="version">v2.18.0</span>).
3787 <div class="collapsible">
3788 <br>
3789 If undefined (or <code>null</code>), the window element will be monitored.<br>
3790 <br>
3791 Use the <a href="#widget-sticky-headers-xscroll"><code>stickyHeaders_xScroll</code></a> option as follows:<br>
3792 <pre class="prettyprint lang-js">$(function() {
3793 $("table").tablesorter({
3794 widgets: ["stickyHeaders"],
3795 widgetOptions : {
3796 // jQuery selector or object to monitor horizontal scroll position (defaults: xScroll > attachTo > window)
3797 stickyHeaders_xScroll : '.wrapper' // $('.wrapper') jQuery object can also be used
3798 }
3799 });
3800 });</pre></div>
3801 </td>
3802 <td><a href="example-widget-sticky-header.html">Example</a></td>
3803 </tr>
3804
3805 <tr id="widget-sticky-headers-yscroll">
3806 <td><a href="#" class="permalink">stickyHeaders_yScroll</a></td>
3807 <td>String, jQuery Object</td>
3808 <td>null</td>
3809 <td>
3810 Sticky Headers widget: points to the element in which to monitor for vertical scrolling (<span class="version">v2.18.0</span>).
3811 <div class="collapsible">
3812 <br>
3813 If undefined (or <code>null</code>), the window element will be monitored.<br>
3814 <br>
3815 Use the <a href="#widget-sticky-headers-yscroll"><code>stickyHeaders_yScroll</code></a> option as follows:<br>
3816 <pre class="prettyprint lang-js">$(function() {
3817 $("table").tablesorter({
3818 widgets: ["stickyHeaders"],
3819 widgetOptions : {
3820 // jQuery selector or object to monitor vertical scroll position (defaults: yScroll > attachTo > window)
3821 stickyHeaders_yScroll : '.wrapper' // $('.wrapper') jQuery object can also be used
3822 }
3823 });
3824 });</pre></div>
3825 </td>
3826 <td><a href="example-widget-sticky-header.html">Example</a></td>
3827 </tr>
3828
3829 <tr id="widget-sticky-headers-offset">
3830 <td><a href="#" class="permalink">stickyHeaders_offset</a></td>
3831 <td>Multiple</td>
3832 <td>0</td>
3833 <td>
3834 Sticky Headers widget: Set the sticky header offset from the top as a <em>Number</em> or jQuery selector <em>string</em> or <em>object</em> (<span class="version">v2.10</span>).
3835 <div class="collapsible">
3836 <br>
3837 If the page includes a fixed navigation bar at the top, like Bootstrap, set <a href="#widget-sticky-headers-offset"><code>&quot;stickyHeaders_offset&quot;</code></a> option to offset the sticky table header to be below the fixed navigation by setting this option using any of the following examples:<br>
3838 <pre class="prettyprint lang-js">$(function() {
3839 $("table").tablesorter({
3840 widgets: ["stickyHeaders"],
3841 widgetOptions : {
3842 // apply sticky header top 30px below the top of the browser window
3843 stickyHeaders_offset : 30
3844 }
3845 });
3846 });</pre>or
3847 <pre class="prettyprint lang-js">stickyHeaders_offset : '.navbar-fixed-top' // jQuery selector string</pre>or
3848 <pre class="prettyprint lang-js">stickyHeaders_offset : $('.navbar-fixed-top') // jQuery object</pre></div>
3849 </td>
3850 <td></td>
3851 </tr>
3852
3853 <tr id="widget-sticky-headers-filtered-to-top">
3854 <td><a href="#" class="permalink">stickyHeaders_filteredToTop</a></td>
3855 <td>Boolean</td>
3856 <td>true</td>
3857 <td>
3858 Sticky Headers widget: Scroll table top into view after filtering (<span class="version">v2.16.2</span>).
3859 <div class="collapsible">
3860 <br>
3861 When a user searches the table using the sticky header filter row the results may reduce the number of rows so that the table would scroll up out of the viewport. So, this option scrolls the table top into view and moves the filter focus to the same input in the original header, instead of the sticky header input.<br>
3862 <br>
3863 Set this option to <code>false</code> to prevent the page scroll after filtering the table.
3864 </div>
3865 </td>
3866 <td></td>
3867 </tr>
3868
3869 <tr id="widget-sticky-headers-addresizeevent">
3870 <td><a href="#" class="permalink">stickyHeaders_addResizeEvent</a></td>
3871 <td>Boolean</td>
3872 <td>true</td>
3873 <td>
3874 Sticky Headers widget: If <code>true</code>, sticky table headers will resize automatically when content is added to or removed from the table headers (<span class="version">v2.10</span>).
3875 <div class="collapsible">
3876 <br>
3877 While this option is <code>true</code>, a timer is initialized to check the width of every header cell every 1/4 second. If this causes lag, or any other problems, set this option to <code>false</code>.
3878 When this option is <code>false</code>, sticky table headers are unable to detect and match the width of the original table headers when content is added or removed.<br>
3879 <br>
3880 Use the <a href="#widget-sticky-headers-addresizeevent"><code>&quot;stickyHeaders_addResizeEvent&quot;</code></a> option as follows:
3881 <pre class="prettyprint lang-js">$(function() {
3882 $("table").tablesorter({
3883 widgets: ["resizable"],
3884 widgetOptions : {
3885 // add header resize detection
3886 stickyHeaders_addResizeEvent : true
3887 }
3888 });
3889 });</pre>When the browser window is resized, the headers (original and sticky) will resize automatically no matter the value of this option.
3890 </div>
3891 </td>
3892 <td></td>
3893 </tr>
3894
3895 <tr id="widget-sticky-headers-zindex">
3896 <td><a href="#" class="permalink">stickyHeaders_zIndex</a></td>
3897 <td>Numeric</td>
3898 <td>2</td>
3899 <td>
3900 Sticky Headers widget: The zIndex added to the stickyHeaders. This option allows the user to adjust the value to their needs (<span class="version">v2.11</span>).
3901 <div class="collapsible">
3902 <br>
3903 Use the <a href="#widget-sticky-headers-zindex"><code>stickyHeaders_zIndex</code></a> option as follows:
3904 <pre class="prettyprint lang-js">$(function() {
3905 $("table").tablesorter({
3906 widgets: ["stickyHeaders"],
3907 widgetOptions : {
3908 // The zIndex of the stickyHeaders, allows the user to adjust this to their needs
3909 stickyHeaders_zIndex : 100
3910 }
3911 });
3912 });</pre></div>
3913 </td>
3914 <td></td>
3915 </tr>
3916
3917 <tr id="widget-resizable">
3918 <td><a href="#" class="permalink">resizable</a></td>
3919 <td>Boolean</td>
3920 <td>true</td>
3921 <td>
3922 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).
3923 <div class="collapsible">
3924 <br>
3925 Use the <a href="#widget-resizable"><code>&quot;resizable&quot;</code></a> option to not save the resized widths:
3926 <pre class="prettyprint lang-js">$(function() {
3927 $("table").tablesorter({
3928 widgets: ["resizable"],
3929 widgetOptions : {
3930 // css class name applied to the sticky header
3931 resizable : false
3932 }
3933 });
3934 });</pre></div>
3935 </td>
3936 <td><a href="example-widget-resizable.html">Example</a></td>
3937 </tr>
3938
3939 <tr id="widget-resizable-addlastcolumn">
3940 <td><a href="#" class="permalink">resizable_addLastColumn</a></td>
3941 <td>Boolean</td>
3942 <td>false</td>
3943 <td>
3944 Resizable widget: If this option is set to <code>true</code>, a resizing anchor will be included in the last column of the table (<span class="version">v2.8.3</span>).
3945 <div class="collapsible">
3946 <br>
3947 If an anchor was included and the table is full width, the column would resize in the opposite direction which my not be intuitive to the user. So set this option as desired, but please be mindful of the user experience.<br>
3948 <br>
3949 Use the <a href="#widget-resizable-addlastcolumn"><code>&quot;resizable_addLastColumn&quot;</code></a> option to include the last column resizer as follows:
3950 <pre class="prettyprint lang-js">$(function() {
3951 $("table").tablesorter({
3952 widgets: ["resizable"],
3953 widgetOptions : {
3954 // css class name applied to the sticky header
3955 resizable_addlastcolumn : true
3956 }
3957 });
3958 });</pre></div>
3959 </td>
3960 <td><a href="example-widget-resizable.html">Example</a></td>
3961 </tr>
3962
3963 <tr id="widget-resizable-includefooter">
3964 <td><a href="#" class="permalink">resizable_includeFooter</a></td>
3965 <td>Boolean</td>
3966 <td>true</td>
3967 <td>Resizable widget: If this option is set to <code>true</code>, the resizable handle will extend into the table footer (<span class="version">v2.28.8</span>).
3968 <div class="collapsible">
3969 <p>When <code>true</code>, this option includes the entire height of the table footer. If the table does not include a footer, the resize handle will stop at the last row.</p>
3970 <p>If <code>false</code>, the resizable handle will not extend into the table footer.</p>
3971 </div>
3972 </td>
3973 <td></td>
3974 </tr>
3975
3976 <tr id="widget-resizable-widths">
3977 <td><a href="#" class="permalink">resizable_widths</a></td>
3978 <td>Array</td>
3979 <td>[]</td>
3980 <td>
3981 Resizable widget: Set this option to the starting &amp; reset header widths (<span class="version">v2.15.12</span>).
3982 <div class="collapsible">
3983 <br>
3984 Use the <a href="#widget-resizable-widths"><code>&quot;resizable_widths&quot;</code></a> option as follows:
3985 <pre class="prettyprint lang-js">$(function() {
3986 $("table").tablesorter({
3987 widgets: ["resizable"],
3988 widgetOptions : {
3989 // headers widths applied at initialization & resizable reset
3990 // this setting includes any non-resizable cells (resizable-false)
3991 resizable_widths : [ '10%', '10%', '50px' ]
3992 }
3993 });
3994 });</pre></div>
3995 </td>
3996 <td><a href="example-widget-resizable.html">Example</a></td>
3997 </tr>
3998
3999 <tr id="widget-resizable-throttle">
4000 <td><a href="#" class="permalink">resizable_throttle</a></td>
4001 <td>Boolean</td>
4002 <td>false</td>
4003 <td>
4004 Resizable widget: Set this option to throttle the resizable events (<span class="version">v2.17.4</span>).
4005 <div class="collapsible">
4006 <br>
4007 When <code>false</code> throttling of the mousemove (resizing) event is not applied.<br>
4008 <br>
4009 Set this option to either <code>true</code> for a default 5 millisecond delay, or set it to any number less than 10 to adjust the throttling delay that is applied to the mousemove/resizing event.<br>
4010 <br>
4011 Use the <a href="#widget-resizable-throttle"><code>&quot;resizable_throttle&quot;</code></a> option as follows:
4012 <pre class="prettyprint lang-js">$(function() {
4013 $("table").tablesorter({
4014 widgets: ["resizable"],
4015 widgetOptions : {
4016 // set to true for a default 5ms throttling delay
4017 // or set to a number &lt; 10 (more than that makes the resizing adjustment unusable
4018 resizable_throttle : true
4019 }
4020 });
4021 });</pre></div>
4022 </td>
4023 <td></td>
4024 </tr>
4025
4026 <tr id="widget-resizable-target-last">
4027 <td><a href="#" class="permalink">resizable_targetLast</a></td>
4028 <td>Boolean</td>
4029 <td>false</td>
4030 <td>
4031 Resizable widget: When <code>true</code>, the last column will be targeted for resizing (<span class="version">v2.21.3</span>).
4032 <div class="collapsible">
4033 <p>When <code>true</code>, resizing a column will change the size of the selected column, and the last column, not the selected column's neighbor.</p>
4034 <p>When <code>false</code>, resizing a column will move the column border between it's neighbors.</p>
4035 <p>Also, in a <em>full width table</em>, if this option is <code>false</code>, the same behavior as when this option is <code>true</code> can be seen when resizing a column while holding down the <kbd>Shift</kbd> key on the keyboard - the last column is resized.</p>
4036 </div>
4037 </td>
4038 <td></td>
4039 </tr>
4040
4041 <tr id="widget-savesort">
4042 <td><a href="#" class="permalink">saveSort</a></td>
4043 <td>Boolean</td>
4044 <td>true</td>
4045 <td>
4046 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).
4047 <div class="collapsible">
4048 <br>
4049 Use the <a href="#widget-savesort"><code>&quot;saveSort&quot;</code></a> option to not save the current sort:
4050 <pre class="prettyprint lang-js">$(function() {
4051 $("table").tablesorter({
4052 widgets: ["saveSort"],
4053 widgetOptions : {
4054 // if false, the sort will not be saved for next page reload
4055 saveSort : false
4056 }
4057 });
4058 });</pre></div>
4059 </td>
4060 <td><a href="example-widget-savesort.html">Example</a></td>
4061 </tr>
4062
4063 <tr id="widget-storage-storage-type">
4064 <td><a href="#" class="permalink">storage_storageType</a></td>
4065 <td>String</td>
4066 <td>&quot;&quot;</td>
4067 <td>
4068 Storage widget: Set this option to the first letter of the desired storage type (<span class="version">v2.28.8</span>).
4069 <div class="collapsible">
4070 <p>If <em>any</em> value is set in this option, the deprecated <a href="#widget-storage-use-session-storage"><code>&quot;storage_useSessionStorage&quot;</code></a> is completely ignored.</p>
4071 <ul>
4072 <li>When set to <code>&quot;s&quot;</code> (session), all saved variables for the table use <code>sessionStorage</code>. This means once the user closes the browser, all saved variables are lost.</li>
4073 <li>When set to <code>&quot;c&quot;</code> (cookie), all saved variables for the table will use cookies.</li>
4074 <li>Any other setting will switch to using the default <code>localStorage</code> type.</li>
4075 </ul>
4076 Use the <a href="#widget-storage-storage-type"><code>&quot;storage_storageType&quot;</code></a> option as follows:
4077 <pre class="prettyprint lang-js">$(function() {
4078 $("table").tablesorter({
4079 widgets: ["saveSort"],
4080 widgetOptions : {
4081 // This sets session storage; only the first letter is required
4082 storage_storageType : "session"
4083 }
4084 });
4085 });</pre></div>
4086 </td>
4087 <td></td>
4088 </tr>
4089
4090 <tr id="widget-storage-use-session-storage">
4091 <td><a href="#" class="permalink alert">storage_useSessionStorage</a></td>
4092 <td>Boolean</td>
4093 <td>false</td>
4094 <td>
4095 Storage widget: This option was <span class="label label-danger">deprecated</span> in <span class="version updated">v2.28.8</span>.
4096 <div class="collapsible">
4097 <p>In <span class="version">v2.28.8</span>, this option is replaced by the <a href="#widget-storage-storage-type"><code>&quot;storage_storageType&quot;</code></a> option and will be completely ignored if that option has <em>any</em> setting.</p>
4098 <p>If this option is set to <code>false</code>, all saved variables for the table will be within local storage (<span class="version">v2.21.3</span>).</p>
4099 <p>If <code>true</code>, all saved variables for the table will be within the session storage. This means once the user closes the browser, all saved variables are lost.</p>
4100 Use the <a href="#widget-storage-use-session-storage"><code>&quot;storage_useSessionStorage&quot;</code></a> option to switch to session storage as follows:
4101 <pre class="prettyprint lang-js">$(function() {
4102 $("table").tablesorter({
4103 widgets: ["saveSort"],
4104 widgetOptions : {
4105 // if false, saved variables will be saved in local storage
4106 storage_useSessionStorage : true
4107 }
4108 });
4109 });</pre></div>
4110 </td>
4111 <td><a href="example-widget-resizable.html">Example</a></td>
4112 </tr>
4113
4114 <tr id="widget-storage-table-id">
4115 <td><a href="#" class="permalink">storage_tableId</a></td>
4116 <td>String</td>
4117 <td>&quot;&quot;</td>
4118 <td>
4119 Storage widget: This option allows setting an alternate table id so multiple tables on a page have the settings grouped together
4120 <div class="collapsible">
4121 <p>When grouping together multiple tables, setting the variable on one table will not cause the setting to modify a second table, the change will only be apparent on page reload.</p>
4122 <p>If this option is not defined, the actual table id will be used (which isn't conducive to applying to multiple tables!)</p>
4123 <p>A more detailed list of the table id priority settings can be found in the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function description.</p>
4124 </div>
4125 </td>
4126 <td></td>
4127 </tr>
4128
4129 <tr id="widget-storage-group">
4130 <td><a href="#" class="permalink">storage_group</a></td>
4131 <td>String</td>
4132 <td>&quot;&quot;</td>
4133 <td>
4134 Storage widget: Set a table (data) attribute to use to obtain a table id, which allows grouping multiple tables on one page together - they share a common saved setting.
4135 <div class="collapsible">
4136 <p>If a value is set in this option, the storage widget looks in that defined table data-attribute for a table id.</p>
4137 <p>If this option is not defined, then the default data-attribute for the table becomes <code>&quot;data-table-group&quot;</code>.</p>
4138 <p>The value in the data-attribute sets a table id, if not found, the storage widget then looks for an id in the <a href="#widget-storage-table-id"><code>storage_tableId</code></a> option.</p>
4139 </div>
4140 </td>
4141 <td></td>
4142 </tr>
4143
4144 <tr id="widget-storage-fixed-url">
4145 <td><a href="#" class="permalink">storage_fixedUrl</a></td>
4146 <td>String</td>
4147 <td>&quot;&quot;</td>
4148 <td>
4149 Storage widget: This option allows setting an alternate table url so that tables on multiple pages will have their settings grouped together
4150 <div class="collapsible">
4151 <p>This option replaces and will override the now deprecated <code>config.fixedUrl</code> option.</p>
4152 <p>If there is a value within the table's "data-table-page" (set by the <code>storage_page</code> option), it will override this setting.</p>
4153 <p>A more detailed list of the table url priority settings can be found in the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function description.</p>
4154 </div>
4155 </td>
4156 <td></td>
4157 </tr>
4158
4159 <tr id="widget-storage-page">
4160 <td><a href="#" class="permalink">storage_page</a></td>
4161 <td>String</td>
4162 <td>&quot;&quot;</td>
4163 <td>
4164 Storage widget: Set a table (data) attribute to use to obtain a table url, which allows grouping tables across multiple pages together - they share a common saved setting.
4165 <div class="collapsible">
4166 <p>If a value is set in this option, the storage widget looks in that defined table data-attribute for a table url.</p>
4167 <p>If this option is not defined, then the default data-attribute for the table becomes <code>&quot;data-table-page&quot;</code>.</p>
4168 <p>The value in the data-attribute sets a table url, if not found, the storage widget then looks for a url in the <a href="#widget-storage-fixed-url"><code>storage_fixedUrl</code></a> option.</p>
4169 </div>
4170 </td>
4171 <td></td>
4172 </tr>
4173
4174 <tr id="widget-zebra">
4175 <td><a href="#" class="permalink">zebra</a></td>
4176 <td>Array</td>
4177 <td>[ &quot;even&quot;, &quot;odd&quot; ]</td>
4178 <td>
4179 Zebra widget: When the zebra striping widget is initialized, it automatically applied the default class names of <code>&quot;even&quot;</code> and <code>&quot;odd&quot;</code>. (Modified v2.1).
4180 <div class="collapsible">
4181 <br>
4182 Use the <a href="#widget-zebra"><code>&quot;zebra&quot;</code></a> option to change the theme as follows:
4183 <pre class="prettyprint lang-js">$(function() {
4184 $("table").tablesorter({
4185 widgets: ["zebra"], // initialize zebra striping of the table
4186 widgetOptions: {
4187 zebra: [ "normal-row", "alt-row" ]
4188 }
4189 });
4190 });</pre></div>
4191 </td>
4192 <td><a href="example-widget-zebra.html">Example</a></td>
4193 </tr>
4194
4195 </tbody>
4196
4197 <!-- non-sorting tbody -->
4198 <tbody id="pager" class="tablesorter-infoOnly">
4199 <tr><th colspan="5">Pager</th></tr>
4200 </tbody>
4201
4202 <tbody>
4203 <tr id="pager-container">
4204 <td><a href="#" class="permalink">container</a></td>
4205 <td>Object</td>
4206 <td>null</td>
4207 <td>
4208 Target your one or more pager markup blocks by setting this option with a jQuery selector.
4209 <div class="collapsible">
4210 <br>
4211 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.container</code>; additionally you can change the class name that is applied to the pager (used within the <code>jquery.tablesorter.pager.css</code> file) by modifying the <code>widgetOption.pager_css.container</code> class name (default is <code>&quot;tablesorter-pager&quot;</code>)<br>
4212 <br>
4213 This is some example pager markup. It <em>should</em> contain all of the controls set by the multiple css-named options:<pre class="prettyprint lang-html">
4214 &lt;div class=&quot;pager&quot;&gt;
4215 &lt;form&gt;
4216 &lt;img src=&quot;first.png&quot; class=&quot;first&quot;/&gt;
4217 &lt;img src=&quot;prev.png&quot; class=&quot;prev&quot;/&gt;
4218 &lt;span class=&quot;pagedisplay&quot;&gt;&lt;/span&gt; &lt;!-- this can be any element, including an input --&gt;
4219 &lt;img src=&quot;next.png&quot; class=&quot;next&quot;/&gt;
4220 &lt;img src=&quot;last.png&quot; class=&quot;last&quot;/&gt;
4221 &lt;select class=&quot;pagesize&quot;&gt;
4222 &lt;option value=&quot;10&quot;&gt;10&lt;/option&gt;
4223 &lt;option value=&quot;20&quot;&gt;20&lt;/option&gt;
4224 &lt;option value=&quot;30&quot;&gt;30&lt;/option&gt;
4225 &lt;option value=&quot;40&quot;&gt;40&lt;/option&gt;
4226 &lt;/select&gt;
4227 &lt;select class="gotoPage" title="Select page number"&gt;&lt;/select&gt;
4228 &lt;/form&gt;
4229 &lt;/div&gt;</pre><span class="label label-warning">Caution</span> If you use buttons in your pager container, make sure the buttons include a button type (<code>&lt;button type=&quot;button&quot;&gt;Next&lt;/button&gt;</code>) to prevent form submission and page reloading every time the button is clicked.<br>
4230 <br>Use this option as follows:<pre class="prettyprint lang-js">$(function() {
4231 $("table")
4232 .tablesorter()
4233 .tablesorterPager({
4234 container: $(".pager")
4235 });
4236 });</pre></div>
4237 </td>
4238 <td><a href="example-pager.html">Example</a></td>
4239 </tr>
4240
4241 <tr id="pager-ajaxurl">
4242 <td><a href="#" class="permalink">ajaxUrl</a></td>
4243 <td>String</td>
4244 <td>null</td>
4245 <td>
4246 Set this option to include a url template to use so that the pager plugin can interact with your database (v2.1; <span class="version updated">v2.9</span>).
4247 <div class="collapsible">
4248 <br>
4249 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxUrl</code><br>
4250 <br>
4251 The tags within the <code>ajaxUrl</code> string are optional. If do not want the user to change the page size, then you only need to include the page in this string:
4252 <pre class="prettyprint lang-js">ajaxUrl: &quot;http://mydatabase.com?start={page}&quot;</pre>
4253 If you need to send your server a page offset (actual starting record number), then you'll need to use the <a href="#pager-customajaxurl"><code>customAjaxUrl</code> option</a>.<br>
4254 <br>
4255 Here is an example of how to include the option, it should <em>always</em> be paired with an <code>ajaxProcessing</code> function:
4256 <pre class="prettyprint lang-js">$(function() {
4257 $("table")
4258 .tablesorter()
4259 .tablesorterPager({
4260 ajaxUrl: "http://mydatabase.com?page={page}&amp;size={size}&amp;{sortList:col}&amp;{filterList:fcol}",
4261 ajaxProcessing: function(data, table, xhr) {
4262 // do something with the ajax data
4263 return [ formatted_data, total_rows ];
4264 }
4265 });
4266 });</pre>The <code>ajaxUrl</code> template replaces the following tags with values from the tablesorter plugin and pager addon:
4267 <br>
4268 <table class="info">
4269 <thead>
4270 <tr><td>Tag</td><td>Replaced with</td></tr>
4271 </thead>
4272 <tbody>
4273 <tr><td><code>{page}</code></td><td>Zero-based index of the current pager page</td></tr>
4274 <tr><td><code>{page+1}</code></td><td>One-based index of the current pager page (replace &quot;+1&quot; with any number) (e.g. <code>{page+3}</code>) (<span class="version">v2.9</span>).</td></tr>
4275 <tr><td><code>{size}</code></td><td>Number of rows showing, or number of rows to get from the server</td></tr>
4276 <tr>
4277 <td><code>{sortList:col}</code> or <code>{sort:col}</code></td>
4278 <td>Adds the current sort to the ajax url string into a "col" array, so your server-side code knows how to sort the data (v2.4.5).<br>
4279 The <code>col</code> portion of the <code>{sortList:col}</code> tag can be any name string (no spaces) to indicate the name of the variable to apply. So if your current sortList is <code>[[2,0],[3,0]]</code>, it becomes <code>&quot;&amp;sort[2]=0&amp;sort[3]=0&quot;</code> in the url. <code>{sort:col}</code> shortened tag also works (<span class="version">v2.9</span>).
4280 </td>
4281 </tr>
4282 <tr>
4283 <td><code>{filterList:fcol}</code> or <code>{filter:fcol}</code></td>
4284 <td>Adds the value of the current filters to the ajax url string into a "fcol" array, so your server-side code knows how to filter the data (v2.6).<br>
4285 The <code>fcol</code> portion of the <code>{filterList:fcol}</code> tag can be any name string (no spaces) to indicate the name of the variable to apply. So if your current filters are <code>['','Blue',13]</code>, it becomes <code>&quot;&amp;fcol[2]=Blue&amp;fcol[3]=13&quot;</code> in the url. <code>{filter:col}</code> shortened tag also works (<span class="version updated">v2.9</span>).
4286 </td>
4287 </tr>
4288 </tbody>
4289 </table></div>
4290 </td>
4291 <td><a href="example-pager-ajax.html">Example</a></td>
4292 </tr>
4293
4294 <tr id="pager-customajaxurl">
4295 <td><a href="#" class="permalink">customAjaxUrl</a></td>
4296 <td>Function</td>
4297 <td>function(table, url) { return url; }</td>
4298 <td>
4299 This callback function allows you to modify the processed URL as desired (<span class="version">v2.8.1</span>).
4300 <div class="collapsible">
4301 <br>
4302 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_customAjaxUrl</code><br>
4303 <br>
4304 The <code>customAjaxUrl</code> function has two parameters, the table DOM element and the processed url string (all tags within the <code>ajaxUrl</code> have been replaced with their appropriate values).
4305 <pre class="prettyprint lang-js">$(function() {
4306 $("table")
4307 .tablesorter()
4308 .tablesorterPager({
4309 ajaxUrl: "http://mydatabase.com?page={page}&amp;size={size}&amp;{sortList:col}&amp;{filterList:fcol}",
4310 ajaxProcessing: function(data, table, xhr) {
4311 // do something with the ajax data
4312 return [ formatted_data, total_rows ];
4313 },
4314 // modify the url after all processing has been applied
4315 customAjaxUrl: function(table, url) {
4316 // trigger my custom event
4317 $(table).trigger('changingUrl');
4318 // send the server the current page
4319 return url += '&amp;currntUrl=' + window.location.href;
4320 }
4321 });
4322 });</pre>
4323 In the following example, lets say your server needs a starting and ending record number instead of a page &amp; size parameter. Use this option as follows:
4324 <pre class="prettyprint lang-js">$(function() {
4325 $("table")
4326 .tablesorter()
4327 .tablesorterPager({
4328 ajaxUrl: "http://mydatabase.com?{sortList:col}",
4329 customAjaxUrl: function(table, url) {
4330 var pager = table.config.pager,
4331 start = pager.page * pager.size,
4332 end = start + pager.size;
4333 return url += '&amp;start=' + start + '&amp;end=' + end;
4334 },
4335 ajaxProcessing: function(data, table, xhr) {
4336 // do something with the ajax data
4337 return [ total_rows, data ];
4338 }
4339 });
4340 });</pre>
4341 </div>
4342 </td>
4343 <td><a href="example-pager-ajax.html">Example</a></td>
4344 </tr>
4345
4346 <tr id="pager-ajaxobject">
4347 <td><a href="#" class="permalink">ajaxObject</a></td>
4348 <td>Object</td>
4349 <td>{ dataType: 'json' }</td>
4350 <td>
4351 This option contains the ajax settings for the pager interaction with your database (<span class="version">v2.10</span>).
4352 <div class="collapsible">
4353 <br>
4354 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxObject</code><br>
4355 <br>
4356 The <code>ajaxObject</code> is completely customizable, except for the <code>url</code> setting which is processed using the pager's <code>ajaxUrl</code> and <code>customAjaxUrl</code> options. This means you can also add a <code>success</code> callback function which is called after the ajax has rendered.<br>
4357 <br>
4358 Your server does not need to return a JSON format, if you want to return pure HTML, set the dataType to <code>&quot;html&quot;</code> and modify the <code>ajaxProcessing</code> function to instead work with HTML; then return a jQuery object or apply the HTML to the table yourself.<br>
4359 <br>
4360 See all possible settings in the <a class="external" href="http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings">jQuery.ajax documentation</a>
4361 <pre class="prettyprint lang-js">$(function() {
4362 $("table")
4363 .tablesorter()
4364 .tablesorterPager({
4365 ajaxUrl: "http://mydatabase.com?page={page}&amp;size={size}&amp;{sortList:col}&amp;{filterList:fcol}",
4366 ajaxObject: {
4367 // add more ajax settings here
4368 // see http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings
4369 dataType: 'json',
4370 type: 'GET'
4371 },
4372 ajaxProcessing: function(data, table, xhr) {
4373 // do something with the ajax data;
4374 return [ total_rows ];
4375 }
4376 });
4377 });</pre></div>
4378 </td>
4379 <td><a href="example-pager-ajax.html">Example</a></td>
4380 </tr>
4381
4382 <tr id="pager-ajaxerror">
4383 <td><a href="#" class="permalink">ajaxError</a></td>
4384 <td>Function</td>
4385 <td>null</td>
4386 <td>
4387 This callback allows you to customize the error message displayed in the <code>thead</code> (<span class="version">v2.23.0</span>; <span class="version updated">v2.23.1</span>).
4388 <div class="collapsible">
4389 <br>
4390 In <span class="version updated">v2.23.1</span>
4391 <ul>
4392 <li>A <code>settings</code> parameter was added <em>before</em> the <code>exception</code> parameter to exactly match the parameters returned by the jQuery <a class="external" href="http://api.jquery.com/ajaxError/">.ajaxError()</a> method.</li>
4393 <li>This function is now always called, even if the <code>$.tablesorter.showError</code> function is called by an external function with only a string.</li>
4394 </ul>
4395 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxError</code><br>
4396 <br>
4397 When there is an ajax error, the <a href="#function-showError"><code>$.tablesorter.showError</code></a> function is called. In <span class="version">v2.23.0</span>, that function now checks this callback to allow adding a custom error message.<br>
4398 <br>
4399 Use it as follows:
4400 <pre class="prettyprint lang-js">$(function() {
4401 $("table")
4402 .tablesorter()
4403 .tablesorterPager({
4404 ajaxError: function( config, xhr, settings, exception ) {
4405 // returning false will abort the error message
4406 // the code below is the default behavior when this callback is set to `null`
4407 return
4408 xhr.status === 0 ? 'Not connected, verify Network' :
4409 xhr.status === 404 ? 'Requested page not found [404]' :
4410 xhr.status === 500 ? 'Internal Server Error [500]' :
4411 exception === 'parsererror' ? 'Requested JSON parse failed' :
4412 exception === 'timeout' ? 'Time out error' :
4413 exception === 'abort' ? 'Ajax Request aborted' :
4414 'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']' );
4415 }
4416 });
4417 });</pre></div>
4418 </td>
4419 <td></td>
4420 </tr>
4421
4422 <tr id="pager-initialrows">
4423 <td><a href="#" class="permalink">initialRows</a></td>
4424 <td>Object</td>
4425 <td>undefined</td>
4426 <td>
4427 When <code>processAjaxOnInit</code> is set to <code>false</code>, set this option to contain the total number of rows and filtered rows to prevent an initial ajax call (<span class="version">v2.25.4</span>).
4428 <div class="collapsible">
4429 <br>
4430 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_initialRows</code>
4431 <p>Use this option as follows:</p>
4432 <pre class="prettyprint lang-js">$(function() {
4433 $("table")
4434 .tablesorter()
4435 .tablesorterPager({
4436 processAjaxOnInit: false,
4437 initialRows: {
4438 total: 100,
4439 filtered: 100
4440 },
4441 // other ajax settings...
4442 });
4443 });</pre>
4444 </div>
4445 </td>
4446 <td></td>
4447 </tr>
4448
4449 <tr id="pager-processajaxoninit">
4450 <td><a href="#" class="permalink">processAjaxOnInit</a></td>
4451 <td>Boolean</td>
4452 <td>true</td>
4453 <td>
4454 Set this option to <code>false</code> if your table data is preloaded into the table, but you are still using ajax (<span class="version">v2.14.5</span>).
4455 <div class="collapsible">
4456 <br>
4457 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_processAjaxOnInit</code>
4458 </div>
4459 </td>
4460 <td></td>
4461 </tr>
4462
4463 <tr id="pager-ajaxprocessing">
4464 <td><a href="#" class="permalink">ajaxProcessing</a></td>
4465 <td>Function</td>
4466 <td>function (data) { return data; }</td>
4467 <td>
4468 This function is required to return the ajax data obtained from your server into a useable format for tablesorter to apply to the table (v2.1, <span class="version updated">v2.30.8</span>).
4469 <div class="collapsible">
4470 <br>
4471 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_ajaxProcessing</code><br>
4472 <br>
4473 This function was created and modified to allow you a great deal of flexibility. The only required information that this function needs to return is an array containing the total number of rows, which is needed to calculate total pages.<br>
4474 <br>
4475 There are numerous examples below. Choosing which one to use is left to you. For more information, please check out related questions on <a class="external" href="http://stackoverflow.com/search?q=%5Btablesorter%5D+ajaxProcessing">Stackoverflow</a>, in particular see <a class="external" href="http://stackoverflow.com/q/16783740/145346">this thread</a> about how to use the different ajax options together.<br>
4476 <br>
4477 In <span class="version">v2.10</span>, the returned rows is now optional. And it can either be an array of arrays or a jQuery object (not attached to the table)<br>
4478 <br>
4479 Process your ajax data so that the following information is returned:<br>
4480 <br>
4481
4482 <div class="accordion">
4483
4484 <h3><a href="#">Object</a></h3>
4485 <div>
4486 After tablesorter <span class="version updated">v2.17.3</span>, this function can include a <code>filteredRows</code> property which will update the internal value and thus show a proper filtered row count, and update the "goto" page drop down selector appropriately.<br>
4487 <br>
4488 After tablesorter <span class="version">v2.11</span>, the <code>ajaxProcessing</code> function can return an object containing these properties, along with any extra properties. These extra properties will be available for use within the pager <code>output</code> string (see more details in <a href="https://github.com/Mottie/tablesorter/issues/326#issuecomment-25326546">issue #326</a>);<br>
4489 <br>
4490 So, lets say the data sent by the server looks like this:
4491 <pre class="prettyprint lang-js">{
4492 "total_rows" : 100,
4493 "filtered_rows" : 75,
4494 "new_headers" : [ "ID", "Name", "Data", "Value" ],
4495 "data" : '&lt;tr&gt;&lt;td&gt;a123&lt;/td&gt;&lt;td&gt;abc&lt;/td&gt;&lt;td&gt;xyz&lt;/td&gt;&lt;td&gt;999&lt;/td&gt;&lt;/tr&gt;',
4496 "subject" : "cheese",
4497 "tasty" : "It's delicious!"
4498 }</pre>
4499 This ajaxProcessing function must return an object with "total", "headers" and "rows" properties! As before, "total" is the only required property; if the headers don't need to be changed, don't return a headers array, and if you append the rows to the table yourself within the ajaxProcessing function, you don't need to return a "rows" property.
4500 <pre class="prettyprint lang-js">ajaxProcessing: function(result, table, xhr) {
4501 if (result && result.hasOwnProperty('data')) {
4502
4503 // "total" is a required property!
4504 result.total = result["total_rows"];
4505
4506 // "filteredRows" is optional - in tablesorter v2.17.3, this updates the filter row count internally
4507 // and updates the "goto" page dropdown selector appropriately
4508 result.filteredRows = result["filtered_rows"];
4509
4510 // "headers" is optional. This is not needed if the table headers don't change
4511 result.headers = result["new_headers"];
4512
4513 // "rows" is optional. No need to return this if you process and add the rows to the table yourself
4514 // otherwise, return an array of arrays or jQuery object (shown in this example)
4515 result.rows = $(result.data);
4516
4517 return result;
4518 }
4519 }</pre>
4520 Now in the <a href="#pager-output"><code>output</code></a> string, you can also reference the extra ajax data:
4521 <pre class="prettyprint lang-js">output : '{startRow} to {endRow} of {filteredRows} ({totalRows}) rows about {subject} ({tasty})'</pre>
4522 </div>
4523
4524 <h3><a href="#">Array (total only)</a></h3>
4525 <div>
4526 After tablesorter <span class="version">v2.10</span>, just build the table yourself and return the total number of rows:
4527 <pre class="prettyprint lang-js">ajaxProcessing: function(data, table, xhr) {
4528 if (data && data.hasOwnProperty('rows')) {
4529 var r, row, c, d = data.rows,
4530 // total number of rows (required)
4531 total = data.total_rows,
4532 // all rows: array of arrays; each internal array has the table cell data for that row
4533 rows = '',
4534 // len should match pager set size (c.size)
4535 len = d.length;
4536 // this will depend on how the json is set up - see City0.json
4537 // rows
4538 for ( r=0; r &lt; len; r++ ) {
4539 rows += '&lt;tr class="ajax-row"&gt;'; // new row
4540 // cells
4541 for ( c in d[r] ) {
4542 if (typeof(c) === "string") {
4543 rows += '&lt;td&gt;' + d[r][c] + '&lt;/td&gt;'; // add each table cell data to row
4544 }
4545 }
4546 rows += '&lt;/tr&gt;'; // end new row
4547 }
4548 // find first sortable tbody, then add new rows
4549 table.config.$tbodies.eq(0).html(rows);
4550 // no need to trigger an update method, it's done internally
4551 return [ total ];
4552 }
4553 }</pre>
4554 </div>
4555
4556 <h3><a href="#">Array (rows as jQuery object)</a></h3>
4557 <div>
4558 After tablesorter <span class="version">v2.10</span>, return a jQuery object
4559 <pre class="prettyprint lang-js">ajaxProcessing: function(data, table, xhr) {
4560 if (data && data.hasOwnProperty('rows')) {
4561 var r, row, c, d = data.rows,
4562 // total number of rows (required)
4563 total = data.total_rows,
4564 // array of header names (optional)
4565 headers = data.headers,
4566 // all rows: array of arrays; each internal array has the table cell data for that row
4567 rows = '',
4568 // len should match pager set size (c.size)
4569 len = d.length;
4570 // this will depend on how the json is set up - see City0.json
4571 // rows
4572 for ( r=0; r &lt; len; r++ ) {
4573 rows += '&lt;tr class="ajax-row"&gt;'; // new row
4574 // cells
4575 for ( c in d[r] ) {
4576 if (typeof(c) === "string") {
4577 rows += '&lt;td&gt;' + d[r][c] + '&lt;/td&gt;'; // add each table cell data to row
4578 }
4579 }
4580 rows += '&lt;/tr&gt;'; // end new row
4581 }
4582 // don't attach the $(rows) because it's difficult to tell old from new data
4583 // and no need to trigger an update method, it's done internally
4584 return [ total, $(rows), headers ];
4585 }
4586 }</pre>
4587 Or, if your JSON contains all the rows within a string this method will work:
4588 <pre class="prettyprint lang-js">ajaxProcessing: function(data, table, xhr) {
4589 if (data && data.hasOwnProperty('rows')) {
4590 // data.rows would look something like this
4591 // '&lt;tr&gt;&lt;td&gt;r0c0&lt;/td&gt;&lt;td&gt;r0c1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;r1c0&lt;/td&gt;&lt;td&gt;r1c1&lt;/td&gt;&lt;/tr&gt;'
4592 return [ data.total, $(data.rows), data.headers ];
4593 }
4594 }</pre>
4595 </div>
4596
4597 <h3><a href="#">Array (rows as an array of arrays)</a></h3>
4598 <div>
4599 After tablesorter v2.1, this function must return an array with values in any of the following orders:
4600 <pre class="prettyprint lang-js">// [ total_rows (number), rows (array of arrays), headers (array; optional) ]
4601 // or [ rows, total_rows, headers ]
4602 // or [ total_rows, $(rows) ]
4603 // or [ total_rows ]
4604 [
4605 100, // total rows
4606 [
4607 [ "row1cell1", "row1cell2", ... "row1cellN" ],
4608 [ "row2cell1", "row2cell2", ... "row2cellN" ],
4609 ...
4610 [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
4611 ],
4612 [ "header1", "header2", ... "headerN" ] // optional
4613 ]</pre><span class="label label-info">Note</span>: In <span class="version">v2.14.3</span>, the contents of the array can also contain table cell markup (i.e. <code>&quot;&lt;td class='green'&gt;+ 10%&lt;/td&gt;&quot;</code>).<br>
4614 <br>
4615 Here is some example JSON (comments added, but not allowed in JSON) which is contained in the <a href="https://github.com/Mottie/tablesorter/blob/master/docs/assets/City0.json">City0.json</a> file:
4616 <pre class="prettyprint lang-js">{
4617 // total rows
4618 "total_rows": 80,
4619 // headers
4620 "cols" : [
4621 "ID", "Name", "Country Code", "District", "Population"
4622 ],
4623 // row data...
4624 "rows" : [{
4625 "ID": 1,
4626 "Name": "Kabul",
4627 "CountryCode": "AFG",
4628 "District": "Kabol",
4629 "Population": 1780000
4630 }, {
4631 // row 2, etc...
4632 }]
4633 }</pre>
4634 The above JSON is processed by the following code (this returns an array of array of table rows):
4635 <pre class="prettyprint lang-js">$(function() {
4636 $("table")
4637 .tablesorter()
4638 .tablesorterPager({
4639 ajaxUrl: "http://mydatabase.com?page={page}&amp;size={size}",
4640 ajaxProcessing: function(data, table, xhr) {
4641 if (data && data.hasOwnProperty('rows')) {
4642 var r, row, c, d = data.rows,
4643 // total number of rows (required)
4644 total = data.total_rows,
4645 // array of header names (optional)
4646 headers = data.cols,
4647 // all rows: array of arrays; each internal array has the table cell data for that row
4648 rows = [],
4649 // len should match pager set size (c.size)
4650 len = d.length;
4651 // this will depend on how the json is set up - see City0.json
4652 // rows
4653 for ( r = 0; r &lt; len; r++ ) {
4654 row = []; // new row array
4655 // cells
4656 for ( c in d[r] ) {
4657 if (typeof(c) === "string") {
4658 row.push(d[r][c]); // add each table cell data to row array
4659 }
4660 }
4661 rows.push(row); // add new row array to rows array
4662 }
4663 return [ total, rows, headers ]; // or return [ rows, total, headers ] in v2.9+
4664 }
4665 }
4666 });
4667 });</pre>
4668 </div>
4669
4670 </div> <!-- end accordion -->
4671 </div> <!-- end collapsible div -->
4672 </td>
4673 <td><a href="example-pager-ajax.html">Example</a></td>
4674 </tr>
4675
4676 <tr id="pager-output">
4677 <td><a href="#" class="permalink">output</a></td>
4678 <td>String</td>
4679 <td>&quot;{startRow} to {endRow} of {totalRows} rows&quot;</td>
4680 <td>This option allows you to format the output display which can show the current page, total pages, filtered pages, current start and end rows, total rows and filtered rows (v2.0.9; <span class="version updated">v2.28.4</span>).
4681 <div class="collapsible">
4682 <br>
4683 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_output</code><br>
4684 <p></p>
4685 In <span class="version updated">v2.28.4</span>
4686 <p>The <a href="#pager-csspagedisplay">output</a> element can now include two data-attributes, <code>data-pager-output</code> and <code>data-pager-output-filtered</code> which override this setting <em>string</em> when set.</p>
4687 <pre class="prettyprint lang-html">&lt;span class=&quot;pagedisplay&quot; data-pager-output=&quot;{startRow:input} &ndash; {endRow} / {totalRows} total rows&quot; data-pager-output-filtered=&quot;{startRow:input} &ndash; {endRow} / {filteredRows} of {totalRows} total rows&quot;&gt;&lt;/span&gt;</pre>
4688 <p>It will not override this option if set as a function, or if a specific <a href="#object">output is returned</a> from the server through ajax.</p>
4689 In <span class="version updated">v2.27.7</span>, this option can also be set as a function
4690 <pre class="prettyprint lang-js">output: function(table, pager) {
4691 return 'page ' + pager.startRow + ' - ' + pager.endRow;
4692 }</pre>
4693 This option replaced the original <code>separator</code> option, which only separated the page number from the total number of pages. The formatted output from this option is placed inside the information block targeted by the <code>cssPageDisplay</code> option.<br>
4694 <br>
4695 Use it as follows:
4696 <pre class="prettyprint lang-js">$(function() {
4697 $("table")
4698 .tablesorter()
4699 .tablesorterPager({
4700 output: '{startRow} to {endRow} of {totalRows} rows'
4701 });
4702 });</pre>The following tags are replaced within the output string:
4703 <table class="info">
4704 <thead>
4705 <tr><td>Tag</td><td>Replaced with</td></tr>
4706 </thead>
4707 <tbody>
4708 <tr><td><code>{size}</code></td><td>The current pager size</td></tr>
4709 <tr><td><code>{page}</code></td><td>The current pager page</td></tr>
4710 <tr><td><code>{page:input}</code></td><td>The current pager page within an input (<span class="version">v2.17.6</span>)</td></tr>
4711 <tr><td><code>{totalPages}</code></td><td>Total number of pager pages</td></tr>
4712 <tr><td><code>{filteredPages}</code></td><td>Total number of pages left after being filtered</td></tr>
4713 <tr><td><code>{startRow}</code></td><td>Starting row number currently displayed</td></tr>
4714 <tr><td><code>{startRow:input}</code></td><td>Starting row number currently displayed within an input (<span class="version">v2.17.6</span>)</td></tr>
4715 <tr><td><code>{endRow}</code></td><td>Ending row number currently displayed</td></tr>
4716 <tr><td><code>{filteredRows}</code></td><td>Total number of rows left after being filtered</td></tr>
4717 <tr><td><code>{totalRows}</code></td><td>Total number of rows</td></tr>
4718 </tbody>
4719 </table></div>
4720 </td>
4721 <td>
4722 <a href="example-pager.html">1</a>
4723 <a href="example-pager-ajax.html">2</a>
4724 <a href="example-pager-filtered.html">3</a>
4725 <a href="example-option-theme-bootstrap-v4.html">4</a>
4726 </td>
4727 </tr>
4728
4729 <tr id="pager-updatearrows">
4730 <td><a href="#" class="permalink">updateArrows</a></td>
4731 <td>Boolean</td>
4732 <td>true</td>
4733 <td>
4734 If <code>true</code>, the addon hides the left pager arrow on the first page and right pager arrow on the last page.
4735 <div class="collapsible">
4736 <br>
4737 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_updateArrows</code><br>
4738 <br>
4739 If <code>true</code> the classname from the <code>cssDisabled</code> option is applied to the arrows when at either page extreme.</div>
4740 </td>
4741 <td><a href="example-pager.html">Example</a></td>
4742 </tr>
4743
4744 <tr id="pager-page">
4745 <td><a href="#" class="permalink">page</a></td>
4746 <td>Numeric</td>
4747 <td>0</td>
4748 <td>
4749 Set the starting page of the pager (zero-based index).
4750 <div class="collapsible">
4751 <br>
4752 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_startPage</code>
4753 </div>
4754 </td>
4755 <td><a href="example-pager.html">Example</a></td>
4756 </tr>
4757
4758 <tr id="pager-page-reset">
4759 <td><a href="#" class="permalink">pageReset</a></td>
4760 <td>Numeric, Boolean</td>
4761 <td>0</td>
4762 <td>
4763 Reset pager to this page after filtering; set to desired page number (zero-based index), or <code>false</code> to not change page at filter start (<span class="version updated">v2.16</span>).
4764 <div class="collapsible">
4765 <br>
4766 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_pageReset</code>
4767 </div>
4768 </td>
4769 <td></td>
4770 </tr>
4771
4772 <tr id="pager-size">
4773 <td><a href="#" class="permalink">size</a></td>
4774 <td>Numeric</td>
4775 <td>10</td>
4776 <td>
4777 Set initial number of visible rows. This value is changed by the dropdown selector targeted by the <a href="#pager-csspagesize"><code>cssPageSize</code></a> option.
4778 <div class="collapsible">
4779 <br>
4780 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_size</code>
4781 <p>Set this option to <code>'all'</code> to show all rows (added <span class="version">v2.26.0</span>).</p>
4782 </div>
4783 </td>
4784 <td><a href="example-pager.html">Example</a></td>
4785 </tr>
4786
4787 <tr id="save-pages">
4788 <td><a href="#" class="permalink">savePages</a></td>
4789 <td>Boolean</td>
4790 <td>true</td>
4791 <td>
4792 Saves the current pager page size and number. This option requires the <a href="#function-storage"><code>$.tablesorter.storage</code></a> script in the <code>jquery.tablesorter.widgets.js</code> file (<span class="version">v2.11</span>).
4793 <div class="collapsible">
4794 <br>
4795 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_savePages</code>
4796 </div>
4797 </td>
4798 <td><a href="example-pager.html">Example</a></td>
4799 </tr>
4800
4801 <tr id="custom-storage">
4802 <td><a href="#" class="permalink">storageKey</a></td>
4803 <td>String</td>
4804 <td>&quot;tablesorter-pager&quot;</td>
4805 <td>
4806 Saves tablesorter paging to custom key if defined. Key parameter name used by the <a href="#function-storage"><code>$.tablesorter.storage</code></a> function. Useful if you have multiple tables defined (<span class="version">v2.15</span>)
4807 <div class="collapsible">
4808 <br>
4809 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_storageKey</code>
4810 </div>
4811 </td>
4812 <td><a href="example-pager.html">Example</a></td>
4813 </tr>
4814
4815 <tr id="pager-fixedheight">
4816 <td><a href="#" class="permalink">fixedHeight</a></td>
4817 <td>Boolean</td>
4818 <td>false</td>
4819 <td>Maintain the height of the table even when fewer than the set number of records is shown (v2.1; updated 2.7.1).
4820 <div class="collapsible">
4821 <br>
4822 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_fixedHeight</code><br>
4823 <br>
4824 This option replaced the original <code>positionFixed</code> and <code>offset</code> options which set the absolute position of the pager block.<br>
4825 <br>
4826 If <code>true</code>, it should maintain the height of the table, even when viewing fewer than the set number of records (go to the last page of any demo to see this in action). It works by adding an empty row to make up the differences in height.
4827 </div>
4828 </td>
4829 <td><a href="example-pager.html">Example</a></td>
4830 </tr>
4831
4832 <tr id="pager-countchildrows">
4833 <td><a href="#" class="permalink">countChildRows</a></td>
4834 <td>Boolean</td>
4835 <td>false</td>
4836 <td>
4837 If <code>true</code>, child rows will be counted towards the pager set size (<span class="version">v2.13</span>).
4838 <div class="collapsible">
4839 <br>
4840 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_countChildRows</code><br>
4841 <br>
4842 <span class="label label-warning">*CAUTION*</span> When <code>true</code>, child row(s) may not appear to be attached to its parent row, may be split across pages or
4843 may distort the table if rowspan or cellspans are included within the child row.<br>
4844 <br>
4845 If this option is <code>false</code>, child row(s) will always appear on the same page as its parent.
4846 </div>
4847 </td>
4848 <td></td>
4849 </tr>
4850
4851 <tr id="pager-removerows">
4852 <td><a href="#" class="permalink">removeRows</a></td>
4853 <td>Boolean</td>
4854 <td>false</td>
4855 <td>
4856 If <code>true</code>, rows are removed from the table to speed up the sort of large tables (v2.0.21).
4857 <div class="collapsible">
4858 <br>
4859 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_removeRows</code><br>
4860 <br>
4861 The original tablesorter plugin (v2.0.5) removed rows automatically, without providing an option. It really does speed up sorting of very large tables, but also breaks updating and modifying table content dynamically.<br>
4862 <br>
4863 If this option is <code>false</code>, the addon only hides the non-visible rows; this is useful if you plan to add/remove rows with the pager enabled.
4864 </div>
4865 </td>
4866 <td><a href="example-pager.html">Example</a></td>
4867 </tr>
4868
4869 <tr id="pager-cssfirst">
4870 <td><a href="#" class="permalink">cssFirst</a></td>
4871 <td>String</td>
4872 <td>&quot;.first&quot;</td>
4873 <td>
4874 This option contains a jQuery selector string pointing to the go to first page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
4875 <div class="collapsible">
4876 <br>
4877 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.first</code>
4878 </div>
4879 </td>
4880 <td><a href="example-pager.html">Example</a></td>
4881 </tr>
4882
4883 <tr id="pager-cssprev">
4884 <td><a href="#" class="permalink">cssPrev</a></td>
4885 <td>String</td>
4886 <td>&quot;.prev&quot;</td>
4887 <td>
4888 This option contains a jQuery selector string pointing to the go to previous page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
4889 <div class="collapsible">
4890 <br>
4891 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.prev</code>
4892 </div>
4893 </td>
4894 <td><a href="example-pager.html">Example</a></td>
4895 </tr>
4896
4897 <tr id="pager-cssnext">
4898 <td><a href="#" class="permalink">cssNext</a></td>
4899 <td>String</td>
4900 <td>&quot;.next&quot;</td>
4901 <td>
4902 This option contains a jQuery selector string pointing to the go to next page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
4903 <div class="collapsible">
4904 <br>
4905 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.next</code>
4906 </div>
4907 </td>
4908 <td><a href="example-pager.html">Example</a></td>
4909 </tr>
4910
4911 <tr id="pager-csslast">
4912 <td><a href="#" class="permalink">cssLast</a></td>
4913 <td>String</td>
4914 <td>&quot;.last&quot;</td>
4915 <td>
4916 This option contains a jQuery selector string pointing to the go to last page arrow. See <a href="#pager-container"><code>container</code></a> for full HTML.
4917 <div class="collapsible">
4918 <br>
4919 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.last</code>
4920 </div>
4921 </td>
4922 <td><a href="example-pager.html">Example</a></td>
4923 </tr>
4924
4925 <tr id="pager-cssgoto">
4926 <td><a href="#" class="permalink">cssGoto</a></td>
4927 <td>String</td>
4928 <td>&quot;.gotoPage&quot;</td>
4929 <td>This option contains a jQuery selector string pointing to the page select dropdown. See <a href="#pager-container"><code>container</code></a> for full HTML (v2.4; <span class="version updated">v2.17.3</span>)
4930 <div class="collapsible">
4931 <br>
4932 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.gotoPage</code> (changed from <code>goto</code> in <span class="version updated">v2.17.3</span>)<br>
4933 <br>
4934 Please note that this select dropdown is initially empty and automatically updated by the plugin with the correct number of pages, which depends on the <a href="#pager-size"><code>size</code></a> setting.
4935 </div>
4936 </td>
4937 <td><a href="example-pager.html">Example</a></td>
4938 </tr>
4939
4940 <tr id="pager-csspagedisplay">
4941 <td><a href="#" class="permalink">cssPageDisplay</a></td>
4942 <td>String</td>
4943 <td>&quot;.pagedisplay&quot;</td>
4944 <td>This option contains a jQuery selector string pointing to the output element (v2.0.9)
4945 <div class="collapsible">
4946 <br>
4947 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.pageDisplay</code><br>
4948 <br>
4949 In the original tablesorter (v2.0.5) this option could only target an input, it was updated (v2.0.9) to display the formatted output from the <code>output</code> option inside of any element (span, div or input).
4950 </div>
4951 </td>
4952 <td><a href="example-pager.html">Example</a></td>
4953 </tr>
4954
4955 <tr id="pager-csspagesize">
4956 <td><a href="#" class="permalink">cssPageSize</a></td>
4957 <td>String</td>
4958 <td>&quot;.pagesize&quot;</td>
4959 <td>
4960 This option contains a jQuery selector string pointing to the page size selector. See <a href="#pager-container"><code>container</code></a> for full HTML.
4961 <div class="collapsible">
4962 <br>
4963 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_selectors.pageSize</code>
4964 </div>
4965 </td>
4966 <td><a href="example-pager.html">Example</a></td>
4967 </tr>
4968
4969 <tr id="pager-csserrorrow">
4970 <td><a href="#" class="permalink">cssErrorRow</a></td>
4971 <td>String</td>
4972 <td>&quot;tablesorter-errorRow&quot;</td>
4973 <td>This option contains the class name that is applied to the error information row that is added inside the pager with any ajax exceptions.
4974 <div class="collapsible">
4975 <br>
4976 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_css.errorRow</code><br>
4977 <br>
4978 Note there is no period "." in front of this class name (it is not a selector).
4979 </div></td>
4980 <td></td>
4981 </tr>
4982
4983 <tr id="pager-cssdisabled">
4984 <td><a href="#" class="permalink">cssDisabled</a></td>
4985 <td>String</td>
4986 <td>&quot;disabled&quot;</td>
4987 <td>This option contains the class name that is applied to disabled pager controls.
4988 <div class="collapsible">
4989 <br>
4990 <span class="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_css.disabled</code><br>
4991 <br>
4992 More explicitly, this class is applied to the pager arrows when they are at either extreme of pages and the <code>updateArrows</code> option is <code>true</code>. When the pager has been disabled, this class is applied to all controls.<br>
4993 <br>
4994 Note there is no period &quot;.&quot; in front of this class name (it is not a selector).
4995 </div></td>
4996 <td></td>
4997 </tr>
4998
4999 </tbody>
5000
5001 <!-- non-sorting tbody -->
5002 <tbody id="pager-removed-options" class="tablesorter-infoOnly">
5003 <tr><th colspan="5">Removed Options</th></tr>
5004 </tbody>
5005
5006 <tbody>
5007
5008 <tr id="widget-filter-anymatch">
5009 <td><a href="#" class="permalink alert">filter_anyMatch</a></td>
5010 <td>Boolean</td>
5011 <td>false</td>
5012 <td>
5013 Filter: This option was <span class="label label-danger">removed</span> in <span class="version updated">v2.15</span>... sorry for the sudden notice.
5014 <div class="collapsible">
5015 <br>
5016 This option has been replaced by the <a href="#widget-filter-external"><code>filter_external</code></a> option.<br>
5017 <br>
5018 Show any rows that match a search query. If this option is <code>true</code> any column match will show that row; but <a href="example-widget-filter-any-match.html#limitations">there are limitations</a> (<span class="version">v2.13.3</span>).<br>
5019 <br>
5020 It is best if this <a href="#widget-filter-anymatch"><code>filter_anyMatch</code></a> option is used with a single search input as follows:
5021 <pre class="prettyprint lang-html">&lt;input class=&quot;search&quot; type=&quot;search&quot;&gt;
5022 &lt;button type=&quot;button&quot; class=&quot;reset&quot;&gt;Reset Search&lt;/button&gt;</pre>
5023 <pre class="prettyprint lang-js">$(function() {
5024 $("table").tablesorter({
5025 widgets: ["filter"],
5026 widgetOptions : {
5027 filter_anyMatch : true,
5028 filter_columnFilters: false,
5029 filter_reset: '.reset'
5030 }
5031 });
5032
5033 // Target the $('.search') input using built in functioning
5034 // this binds to the search using "search" and "keyup"
5035 // Allows using filter_liveSearch or delayed search &
5036 // pressing escape to cancel the search
5037 $.tablesorter.filter.bindSearch( $table, $('.search') );
5038
5039 });</pre></div>
5040 </td>
5041 <td></td>
5042 </tr>
5043
5044 <tr id="widget-uitheme">
5045 <td><a href="#" class="permalink alert">uitheme</a></td>
5046 <td>String</td>
5047 <td>&quot;jui&quot;</td>
5048 <td>UiTheme: This option was <span class="label label-danger">removed</span> in v2.19.0!
5049 It has been replaced by <a href="#theme">theme</a>.
5050 <div class="collapsible"><br>
5051 This option contains the name of the theme. Currently jQuery UI (&quot;jui&quot;) and Bootstrap (&quot;bootstrap&quot;) themes are supported (updated v2.4)
5052 <p>
5053 <span class="label label-warning">* NOTE *</span> only the <code>uitheme</code> widget option was removed. All of the information below is still pertinent and portions have been copied to the core <a href="#theme"><code>theme</code></a> option.
5054 </p>
5055 <p>To modify the class names used, extend from the <a href="#variable-themes"><code>$.tablesorter.themes</code></a> variable as follows:</p>
5056 <pre class="prettyprint lang-js">// Extend the themes to change any of the default class names ** NEW **
5057 $.extend($.tablesorter.themes.jui, {
5058 // change default jQuery uitheme icons - find the full list of icons
5059 // here: http://jqueryui.com/themeroller/ (hover over them for their name)
5060 table : 'ui-widget ui-widget-content ui-corner-all', // table classes
5061 caption : 'ui-widget-content',
5062 // header class names
5063 header : 'ui-widget-header ui-corner-all ui-state-default', // header classes
5064 sortNone : '',
5065 sortAsc : '',
5066 sortDesc : '',
5067 active : 'ui-state-active', // applied when column is sorted
5068 hover : 'ui-state-hover', // hover class
5069 // icon class names
5070 icons : 'ui-icon', // icon class added to the &lt;i&gt; in the header
5071 iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // "caret" class renamed in jQuery v1.12.0
5072 iconSortAsc : 'ui-icon-carat-1-n ui-icon-caret-1-n',
5073 iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s',
5074 // other
5075 filterRow : '',
5076 footerRow : '',
5077 footerCells : '',
5078 even : 'ui-widget-content', // even row zebra striping
5079 odd : 'ui-state-default' // odd row zebra striping
5080 });</pre>
5081
5082 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>
5083 <br>
5084
5085 The class names from the <code>$.tablesorter.themes.{name}</code> variable are applied to the table as indicated.<br>
5086 <br>
5087
5088 As before the jQuery UI theme applies the default class names of <code>&quot;ui-icon-arrowthick-2-n-s&quot;</code> for the unsorted column, <code>&quot;ui-icon-arrowthick-1-s&quot;</code> for the descending sort and <code>&quot;ui-icon-arrowthick-1-n&quot;</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>
5089 <br>
5090 Use the <a href="#widget-uitheme"><code>&quot;uitheme&quot;</code></a> option to change the css class name as follows:
5091 <pre class="prettyprint lang-js">$(function() {
5092 $("table").tablesorter({
5093 theme : 'jui', // set theme name from $.tablesorter.themes here
5094 widgets : ["uitheme"], // initialize ui theme styling widget of the table
5095 widgetOptions: {
5096 uitheme : "jui" // this is now optional in v2.7, it is overridden by the theme option
5097 }
5098 });
5099 });</pre>
5100
5101 To add a new theme, define it as follows; replace "custom" with the name of your theme:
5102 <pre class="prettyprint lang-js">$.tablesorter.themes.custom = {
5103 table : 'table', // table classes
5104 header : 'header', // header classes
5105 footerRow : '',
5106 footerCells: '',
5107 icons : 'icon', // icon class added to the &lt;i&gt; in the header
5108 sortNone : 'sort-none', // unsorted header
5109 sortAsc : 'sort-asc', // ascending sorted header
5110 sortDesc : 'sort-desc', // descending sorted header
5111 active : 'sort-active', // applied when column is sorted
5112 hover : 'hover', // hover class
5113 filterRow : 'filters', // class added to the filter row
5114 even : 'even', // even row zebra striping
5115 odd : 'odd' // odd row zebra striping
5116 }</pre></div>
5117 </td>
5118 <td><a href="example-widget-ui-theme.html">Example</a></td>
5119 </tr>
5120
5121 <tr id="pager-offset">
5122 <td><a href="#" class="permalink alert">offset</a></td>
5123 <td>Numeric</td>
5124 <td>0</td>
5125 <td>
5126 Pager: This option was <span class="label label-danger">removed</span>!
5127 <div class="collapsible">
5128 <br>
5129 The original tablesorter pager plugin absolutely positioned the pager controls at the bottom of the table. It appears that this option was intended to tweak the position of the pager container. The option exists, but no code was found.</div>
5130 </td>
5131 <td></td>
5132 </tr>
5133
5134 <tr id="pager-positionfixed">
5135 <td><a href="#" class="permalink alert">positionFixed</a></td>
5136 <td>Boolean</td>
5137 <td>true</td>
5138 <td>
5139 Pager: This option was <span class="label label-danger">removed</span>!
5140 <div class="collapsible">
5141 <br>
5142 If this option were true, the original tablesorter pager plugin would absolutely position the pager controls at the bottom of the table.</div>
5143 </td>
5144 <td></td>
5145 </tr>
5146
5147 <tr id="pager-seperator">
5148 <td><a href="#" class="permalink alert">seperator</a></td>
5149 <td>String</td>
5150 <td>&quot;/&quot;</td>
5151 <td>
5152 Pager: This option was <span class="label label-danger">removed</span>! Use the <a href="#pager-output">output</a> option to allow for more control over the formatting.
5153 <div class="collapsible">
5154 <br>
5155 The original tablesorter pager plugin would combine the current page with the calculated total number of pages within the <a href="#pager-csspagedisplay">cssPageDisplay</a> with this separator string inbetween.</div>
5156 </td>
5157 <td></td>
5158 </tr>
5159 </tbody>
5160
5161 </table>
5162
5163 <a id="methods"></a>
5164 <h1>Methods</h1>
5165
5166 <div class="tip">
5167 <p></p>
5168 tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
5169 <br>
5170 <span class="label label-info">TIP!</span> 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.
5171 </div>
5172
5173 <table id="method" class="tablesorter-blue options" data-sortlist="[[0,0]]">
5174 <thead>
5175 <tr>
5176 <th>Method</th>
5177 <th class="sorter-false">Description</th>
5178 <th class="sorter-false">Link</th>
5179 </tr>
5180 </thead>
5181 <tbody>
5182
5183 <tr id="addrows">
5184 <td><a href="#" class="permalink">addRows</a></td>
5185 <td>Use this method to add table rows (v2.0.16; <span class="version updated">v2.23.0</span>).
5186 <div class="collapsible">
5187 <h4>Direct method:</h4>
5188 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5189 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5190 $rows = $( 'tr.addedRows' ), // jQuery selector of newly appended row(s)
5191 // applies or reapplies a sort to the table; use false to not update the sort
5192 resort = true, // or [ [0,0], [1,0] ] etc
5193 callback = function( table ) {
5194 // do something
5195 };
5196 $.tablesorter.addRows( config, $rows, resort, callback );</pre>
5197 <h4>Triggered event method:</h4>
5198 It does not work the same as &quot;update&quot; in that it only adds rows, it does not remove them.<br>
5199 <br>
5200 Also, use this method to add table rows while using the pager plugin. If the &quot;update&quot; method is used, only the visible table rows continue to exist.
5201 <pre class="prettyprint lang-js">// Add multiple rows to the table
5202 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;' +
5203 '&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;',
5204 $row = $( row ),
5205 // resort table using true to reapply the current sort; set to false to prevent resort
5206 // if undefined, the resort value will be obtained from config.resort (added v2.19.0)
5207 // As of v2.19.0, the resort variable can contain a new sortList to be applied
5208 // A callback method was added in 2.3.9.
5209 resort = true, // or [ [0,0], [1,0] ] etc
5210 callback = function( table ) {
5211 alert( 'rows have been added!' );
5212 };
5213 $( 'table' )
5214 .find( 'tbody' ).append( $row )
5215 .trigger( 'addRows', [ $row, resort, callback ] );</pre>
5216 <hr>
5217 <ul>
5218 <li>In <span class="version">v2.23.0</span>,
5219 <ul>
5220 <li>If a table contains only one tbody (not counting information only tbodies; which have a class name from <code>cssInfoBlock</code>), then a row string can be used in this method.
5221 <pre class="prettyprint lang-js">var $table = $( 'table' ),
5222 config = $table[ 0 ].config;
5223 // triggered event method
5224 $table.trigger( 'addRows', [ '&lt;tr&gt;...&lt;/tr&gt;', true ] );
5225
5226 // direct method
5227 $.tablesorter.addRows( config, '&lt;tr&gt;...&lt;/tr&gt;', true );</pre></li>
5228 <li>So instead of making a jQuery object, appending it to the table, then passing the reference to the method, you can just pass a string. This method doesn't work if a table has multiple tbodies, because the plugin doesn't know where you want to add the rows.</li>
5229 </ul>
5230 </li>
5231 <li>In <span class="version">v2.16.1</span>, the <code>$row</code> parameter can be a row DOM element or jQuery object.</li>
5232 </ul>
5233 </div>
5234 </td>
5235 <td><a href="example-add-rows.html">Example</a></td>
5236 </tr>
5237
5238 <tr id="resettoloadstate">
5239 <td><a href="#" class="permalink">resetToLoadState</a></td>
5240 <td>Use this method reset the table to it's original settings. (<span class="version">v2.17.0</span>).
5241 <div class="collapsible">
5242 Using this method will clear out any settings that have changed since the table was initialized (refreshes the entire table); so any sorting or modified widget options will be cleared.<br>
5243 However, it will not clear any values that were saved to storage. This method is basically like reloading the page.
5244 <pre class="prettyprint lang-js">$('table').trigger('resetToLoadState');</pre>
5245 </div>
5246 </td>
5247 <td></td>
5248 </tr>
5249
5250 <tr id="sort">
5251 <td><a href="#" class="permalink">sort</a></td>
5252 <td>Use this method to initialize a sort while targeting a specific column header (<span class="version">v2.9</span>).
5253 <div class="collapsible">
5254 <pre class="prettyprint lang-js">// Target a specific header
5255 $('table').find('th:eq(2)').trigger('sort');</pre>Using this method will maintain the sorting order; so, if the column is already sorted in ascending order, this method will act as if you manually clicked on the header. Whatever sort order is applied is dependent on other option settings such as <code>initialSortOrder</code>, <code>lockedOrder</code> (set within the <code>headers</code>), <code>sortReset</code> option, <code>sortRestart</code> and will be ignored if the column sort is disabled (<code>sorter: false</code>).
5256 </div>
5257 </td>
5258 <td></td>
5259 </tr>
5260
5261 <tr id="sorton">
5262 <td><a href="#" class="permalink">sorton</a></td>
5263 <td>Use this method to sort an initialized table in the desired order (<span class="version updated">v2.23.0</span>)
5264 <div class="collapsible">
5265 <h4>Direct method:</h4>
5266 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5267 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5268 sort = [ [ 0,0 ], [ 1,0 ] ],
5269 callback = function( table ) {
5270 // do something
5271 };
5272 // NOTE: the triggered 'sorton' method requires the sort & callback methods to be
5273 // passed inside an array, this direct method does not.
5274 // Also, notice the "O" of "sortOn" is capitalized in this direct method
5275 $.tablesorter.sortOn( config, sort, callback );</pre>
5276 <h4>Triggered event method:</h4>
5277 <pre class="prettyprint lang-js">// Choose a new sort order
5278 var sort = [ [0,0], [2,0] ],
5279 callback = function( table ) {
5280 alert( 'new sort applied to ' + table.id );
5281 };
5282 // Note that the sort value below is inside of another array (inside another set of square brackets)
5283 // without a callback it could look like this:
5284 $( 'table' ).trigger( 'sorton', [ [[0,0],[2,0]] ] );
5285
5286 // when including a callback method the outer square bracket wrap both parameters (added in 2.3.9).
5287 $( 'table' ).trigger( 'sorton', [ sort, callback ] );</pre>
5288 <span class="label label-warning">*NOTE*</span> using this method to sort ignores the additions from the <a href="#sortforce"><code>sortForce</code></a> and <a href="#sortappend"><code>sortAppend</code></a> options.<br>
5289 <br>
5290 In <span class="version updated">v2.17.0</span>, the sort direction can be set using "a" (ascending), "d" (descending), "n" (next), "s" (same) &amp; "o" (opposite).
5291 <pre class="prettyprint lang-js">$('table').trigger('sorton', [ [[0,"a"],[2,"n"]] ]);</pre>
5292 Please try out the demo (example link) to better understand how these values work.
5293 </div>
5294 </td>
5295 <td><a href="example-trigger-sort.html">Example</a></td>
5296 </tr>
5297
5298 <tr id="sortreset-method">
5299 <td><a href="#" class="permalink">sortReset</a></td>
5300 <td>Use this method to set the table into an unsorted state (v2.4.7; <span class="version updated">v2.23.0</span>).
5301 <div class="collapsible">
5302 <h4>Direct method:</h4>
5303 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5304 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5305 callback = function( table ) {
5306 // do something
5307 };
5308 $.tablesorter.sortReset( config, callback );</pre>
5309 <h4>Triggered event method:</h4>
5310 This method immediately resets the entire table sort, while the option only resets the column sort after a third click.<br>
5311 <br>
5312 In <span class="version updated">v2.16.0</span>, a callback function was added to this method.<br>
5313 <br>
5314 <pre class="prettyprint lang-js">// Reset the table (make it unsorted)
5315 var callback = function( table ) {
5316 console.log( 'sort has been reset' );
5317 };
5318 $( 'table' ).trigger( 'sortReset', [ callback ] );</pre>
5319 <span class="label label-warning">*NOTE*</span> Don't confuse this method with the <a href="#sortreset"><code>sortReset</code> option</a>.
5320 </div>
5321 </td>
5322 <td><a href="example-method-sortreset.html">Example</a></td>
5323 </tr>
5324
5325 <tr id="update">
5326 <td><a href="#" class="permalink">update</a> / <a href="#" class="permalink">updateRows</a></td>
5327 <td>Update the <code>tbody</code>'s stored data (<code>update</code> &amp; <code>updateRows</code> do exactly the same thing; <span class="version updated">v2.23.0</span>)
5328 <div class="collapsible">
5329 <h4>Direct method:</h4>
5330 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5331 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5332 // applies or reapplies a sort to the table; use false to not update the sort
5333 resort = true, // or [ [0,0], [1,0] ] etc
5334 callback = function( table ) {
5335 // do something
5336 };
5337 $.tablesorter.update( config, resort, callback );</pre>
5338 <h4>Triggered event method:</h4>
5339 <pre class="prettyprint lang-js">// Add new content
5340 $( 'table tbody' ).append( html );
5341
5342 // let the plugin know that we made a update
5343 // the resort flag set to true will trigger an automatic resort using the current sort
5344 // if set to false, no new sort will be applied; or set it to any sortList value (e.g. [[0,0]]; new v2.19.0)
5345 // A callback method was added in 2.3.9.
5346 var resort = true,
5347 callback = function( table ) {
5348 alert( 'new sort applied' );
5349 };
5350 $( 'table' ).trigger( 'update', [ resort, callback ] );
5351
5352 // As of version 2.19.0, if the resort parameter is undefined, the setting from the config.resort will be used
5353
5354 // As of version 2.0.14, the table will automatically resort after the update (if the "resort" flag is true
5355 // &amp; will use the current sort selection), so include the following if you want to specify a different sort
5356
5357 // set sorting column and direction, this will sort on the first and third column
5358 var sorting = [ [2,1], [0,0] ];
5359 // method to use prior to v2.19.0
5360 // $( 'table' )
5361 // .trigger( 'update', [ false ] )
5362 // .trigger( 'sorton', [ sorting ] );
5363 // After v2.19.0; do the following to apply a new sort after updating
5364 // if sorting is an empty array [], then the sort will be reset
5365 $( 'table' ).trigger( 'update', [ sorting ] );</pre>
5366 <span class="label label-info">NOTE</span> <code>updateRows</code> was added to work around the issue of using jQuery with the Prototype library. Triggering an "update" would make Prototype clear the tbody; Please see <a href="https://github.com/Mottie/tablesorter/issues/217">issue #217</a> for more details.
5367 </div>
5368 </td>
5369 <td><a href="example-ajax.html">Example</a></td>
5370 </tr>
5371
5372 <tr id="updateall">
5373 <td><a href="#" class="permalink">updateAll</a></td>
5374 <td>Update a column of cells (<code>thead</code> and <code>tbody</code>) (<span class="version">v2.8</span>; <span class="version updated">v2.23.0</span>).
5375 <div class="collapsible">
5376 <h4>Direct method:</h4>
5377 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5378 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5379 // applies or reapplies a sort to the table; use false to not update the sort
5380 resort = true, // or [ [0,0], [1,0] ] etc
5381 callback = function( table ) {
5382 // do something
5383 };
5384 $.tablesorter.updateAll( config, resort, callback );</pre>
5385 <h4>Triggered event method:</h4>
5386 <pre class="prettyprint lang-js">// Change thead & tbody column of cells
5387 // remember, "eq()" is zero based & "nth-child()" is 1 based
5388 $("table thead th:eq(2)").html("Number");
5389 // add some random numbers to the table cell
5390 $("table tbody").find('td:nth-child(3)').html(function(i,h) {
5391 return Math.floor(Math.random()*10) + 1; // random number from 0 to 10
5392 });
5393
5394 // reapply the current sort if resort = true
5395 // do not reapply the current sort if resort = false
5396 // if undefined, resort will be obtained from config.resort (added v2.19.0)
5397 // as of v2.19.0, apply a new sort if resort = [[0,0]] (or whatever)
5398 // or the sort is reset if resort = []
5399 var resort = true,
5400 // add a callback, as desired
5401 callback = function(table) {
5402 alert('table updated!');
5403 };
5404
5405 // let the plugin know that we made a update, then the plugin will
5406 // automatically sort the table based on the header settings
5407 $("table").trigger("updateAll", [ resort, callback ]);</pre></div>
5408 </td>
5409 <td><a href="example-update-all.html">Example</a></td>
5410 </tr>
5411
5412 <tr id="updatecache">
5413 <td><a href="#" class="permalink">updateCache</a></td>
5414 <td>Update the parsers, only if not defined, then update the internal cache (<span class="version">v2.15.4</span>; <span class="version updated">v2.27.0</span>).
5415 <div class="collapsible">
5416 <h4>Direct method:</h4>
5417 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5418 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5419 // optional parameter to target tbodies
5420 $tbodies = $( 'table' ).children( 'tbody.totals' ),
5421 callback = function( table ) {
5422 // do something
5423 };
5424 $.tablesorter.updateCache( config, callback, $tbodies );</pre>
5425 <h4>Triggered event method:</h4>
5426 <p><span class="label label-warning">*NOTE*</span> In <span class="version updated">v2.22.2</span>, a new parameter was added to allow passing a jQuery object containing tbodies to be added to the table (for the tbody sorting widget).</p>
5427 <p>This method is used by the pager (addon &amp; widget) to update the data stored within the cache after the content has been updated using ajax.</p>
5428 <pre class="prettyprint lang-js">// optional callback function
5429 var callback = function( table ) { /* do something */ },
5430 // optional in v2.22.2; defaults to table.config.$tbodies if undefined
5431 $tbodies = $( 'table' ).children( 'tbody' );
5432 $("table").trigger("updateCache", [ callback, $tbodies ] );</pre></div>
5433 </td>
5434 <td><a href="example-update-all.html">Example</a></td>
5435 </tr>
5436
5437 <tr id="appendcache">
5438 <td><a href="#" class="permalink">appendCache</a></td>
5439 <td>Adds all of the cached table rows back into the table (<span class="version updated">v2.23.0</span>).<br>
5440 <div class="collapsible"><br>
5441 This method was originally designed to be used with the pager. It should be used under these conditions:
5442 <ul>
5443 <li>When the pager <code>removeRows</code> option is <code>true</code>.</li>
5444 <li>When not using the &quot;updateCell&quot; or &quot;addRows&quot; methods.</li>
5445 <li>Before manually adding or removing table rows.</li>
5446 <li>And, before triggering an &quot;update&quot;.</li>
5447 </ul>
5448 Note: The entire table is stored in the cache, but when using the pager with the <a href="#pager-removerows"><code>removeRows</code> option</a> set to <code>true</code>, only the visible portion is actually exists within the table. So, use this option to add all stored rows back into the table before manually changing the contents. Otherwise, if any update method is triggered, only the visible rows will be added back to the cache.
5449 <h4>Direct method:</h4>
5450 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5451 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config;
5452 // there is no callback available when using this direct method because
5453 // it may divert to pager injected functions, if the pager is being used
5454 $.tablesorter.appendCache( config );</pre>
5455 <h4>Triggered event method:</h4>
5456 <pre class="prettyprint lang-js">// how to update the table contents
5457 $("table")
5458 .trigger("appendCache")
5459 .append('&lt;tr&gt;...&lt;/tr&gt;') // add new row(s), or delete rows
5460 .trigger("update"); // update the cache</pre>
5461 </div>
5462 </td>
5463 <td></td>
5464 </tr>
5465
5466 <tr id="updateheaders">
5467 <td><a href="#" class="permalink">updateHeaders</a></td>
5468 <td>Refresh table headers only (<span class="version">v2.23.0</span>).
5469 <div class="collapsible">
5470 <h4>Direct method:</h4>
5471 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5472 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5473 callback = function( table ) {
5474 // do something
5475 };
5476 $.tablesorter.updateHeaders( config, callback );</pre>
5477 <h4>Triggered event method:</h4>
5478 <pre class="prettyprint lang-js">$(function() {
5479 $( 'table' ).tablesorter();
5480
5481 // click on a button somewhere on the page to update header index
5482 $( 'button' ).click( function() {
5483 // Do something after the cell update in this callback function
5484 var $headerCell = $('thead th:eq(1)'),
5485 index = $headerCell.data( 'counter' ) || 0,
5486 callback = function( table ) {
5487 /* do something */
5488 };
5489
5490 // change header text
5491 $headerCell
5492 .html( 'header click #' + index )
5493 // update header data
5494 .data( 'counter', index++ );
5495
5496 // update the header, includes rebinding events & using the header template
5497 $( 'table' ).trigger( 'updateHeaders', callback );
5498 return false;
5499 });
5500 });</pre></div>
5501 </td>
5502 <td></td>
5503 </tr>
5504
5505 <tr id="updatecell">
5506 <td><a href="#" class="permalink">updateCell</a></td>
5507 <td>Update a table cell in the tablesorter data (<span class="version updated">v2.23.0</span>).
5508 <div class="collapsible">
5509 <h4>Direct method:</h4>
5510 <p>In <span class="version">v2.23.0</span>, this method can be called directly as follows:</p>
5511 <pre class="prettyprint lang-js">var config = $( 'table' )[ 0 ].config,
5512 $cell = $( 'td.random' ), // jQuery selector or DOM element of newly updated cell
5513 // applies or reapplies a sort to the table; use false to not update the sort
5514 resort = true, // or [ [0,0], [1,0] ] etc
5515 callback = function( table ) {
5516 // do something
5517 };
5518 $.tablesorter.updateCell( config, $cell, resort, callback );</pre>
5519 <h4>Triggered event method:</h4>
5520 <pre class="prettyprint lang-js">$(function() {
5521 $( 'table' ).tablesorter();
5522
5523 $( 'td.discount' ).click( function() {
5524
5525 // Do we want to reapply the current sort on the column?
5526 // see updateRow for other resort settings as of v2.19.0
5527 // if resort is undefined, the value from config.resort (added v2.19.0) will be used
5528 var resort = false,
5529 // Do something after the cell update in this callback function
5530 callback = function( table ) {
5531 /* do something */
5532 },
5533 // randomize a number & add it to the cell
5534 discount = '$' + Math.round( Math.random() * Math.random() * 100 ) + '.' +
5535 ( '0' + Math.round( Math.random() * Math.random() * 100 ) ).slice( -2 );
5536
5537 // add new table cell text
5538 $( this ).text( discount );
5539
5540 // update the table, so the tablesorter plugin can update its value
5541 // set resort flag to false to prevent automatic resort (since we're using a different sort below)
5542 // prior to v2.19.0, leave the resort flag as undefined, or with any other value, to automatically resort the table
5543 // new resort values can be set as of v2.19.0 - please see the "updateRow" documentation for more details
5544 // $( 'table' ).trigger( 'updateCell', [ this ] ); &lt; - resort is undefined so the table WILL resort
5545 $( 'table' ).trigger( 'updateCell', [ this, resort, callback ] );
5546
5547 // As of version 2.0.14, the table will automatically resort (using the current sort selection)
5548 // after the update, so include the following if you want to specify a different sort
5549
5550 // prior to v2.19.0, set sorting column and direction, this will sort on the first and third column
5551 // after v2.19.0, add any new sort to the "resort" variable above
5552 var sorting = [ [ 3,1 ] ];
5553 $( 'table' ).trigger( 'sorton', [ sorting ] );
5554
5555 return false;
5556 });
5557 });</pre></div>
5558 </td>
5559 <td><a href="example-update-cell.html">Example</a></td>
5560 </tr>
5561
5562 <tr id="applywidgetid">
5563 <td><a href="#" class="permalink">applyWidgetId</a></td>
5564 <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 (<span class="version updated">v2.25.4</span>).
5565 <div class="collapsible">
5566 <p>In <span class="version updated">v2.25.4</span>, the direct method will now correctly accept <code>$('table')</code>. Previously, only <code>$('table')[0]</code> would work.</p>
5567 <p>In <span class="version updated">v2.25.0</span>, this method ensures that the widget initialization code is executed as well as the format function. So now a widget that was not previously initialized or had been previously removed, can be reapplied.</p>
5568 <p>Only <em>one</em> widget can be applied at a time using this method.</p>
5569 <h4>Direct method:</h4>
5570 <pre class="prettyprint lang-js">$.tablesorter.applyWidgetId( $('table'), 'zebra' );</pre>
5571 <h4>Triggered event method:</h4>
5572 <pre class="prettyprint lang-js">$(function() {
5573 // initialize tablesorter without the widget
5574 $('table').tablesorter();
5575
5576 // click a button to apply the zebra striping
5577 $('button').click(function() {
5578 $('table').trigger('applyWidgetId', 'zebra');
5579 return false;
5580 });
5581
5582 });</pre></div>
5583 </td>
5584 <td><a href="example-apply-widget.html">Example</a></td>
5585 </tr>
5586
5587 <tr id="applywidgets">
5588 <td><a href="#" class="permalink">applyWidgets</a></td>
5589 <td>Apply the set widgets to the table (<span class="version updated">v2.29.0</span>).
5590 <div class="collapsible">
5591 <p>In <span class="version updated">v2.29.0</span>, access to the callback method was added.</p>
5592 <p>This method only updates the widgets listed in the <a href="#widgets"><code>table.config.widgets</code></a> option.</p>
5593 <pre class="prettyprint lang-js">// This method applies the widgets already added to tablesorter
5594 $('table').trigger('applyWidgets', callback);
5595 </pre>
5596 Use this method can be used to add multiple widgets to the table.
5597 <pre class="prettyprint lang-js">var $table = $( 'table' );
5598 $table[0].config.widgets = [ 'zebra', 'columns' ];
5599 $table.trigger('applyWidgets', function() {
5600 console.log('new widgets applied');
5601 });
5602 </pre></div>
5603 </td>
5604 <td><a href="example-apply-widget.html">Example</a></td>
5605 </tr>
5606
5607 <tr id="removewidget">
5608 <td><a href="#" class="permalink">removeWidget</a></td>
5609 <td>Remove the named widget from the table (<span class="version">v2.25.0</span>).
5610 <div class="collapsible">
5611 <p>This method will remove the named widget(s) from the table.</p>
5612 <h4>Direct method:</h4>
5613 <pre class="prettyprint lang-js">$.tablesorter.removeWidget( $( 'table' ), widget );</pre>
5614 <h4>Triggered event method:</h4>
5615 <pre class="prettyprint lang-js">$( 'table' ).trigger( 'removeWidget', widget );</pre>
5616 <p>The <code>widget</code> parameter can be used as follows:</p>
5617 <ul>
5618 <li>Single widget name - string
5619 <pre class="prettyprint lang-js">// only remove zebra widget
5620 $( 'table' ).trigger( 'removeWidget', 'zebra' );</pre>
5621 </li>
5622 <li>Multiple widgets names - array or string (space or comma separated)
5623 <pre class="prettyprint lang-js">// remove multiple widgets (the below methods are all equivalent)
5624 $( 'table' ).trigger( 'removeWidget', 'zebra columns' );
5625 $( 'table' ).trigger( 'removeWidget', 'zebra, columns' );
5626 $( 'table' ).trigger( 'removeWidget', [ 'zebra', 'columns' ] );</pre>
5627 </li>
5628 <li><code>true</code> - boolean (removes all widgets; passing <code>false</code> does nothing)
5629 <pre class="prettyprint lang-js">// remove all widgets
5630 $( 'table' ).trigger( 'removeWidget', true );</pre>
5631 </li>
5632 </ul>
5633 </div>
5634 </td>
5635 <td><a href="example-apply-widget.html">Example</a></td>
5636 </tr>
5637
5638 <tr id="destroy">
5639 <td><a href="#" class="permalink">destroy</a></td>
5640 <td>Use this method to remove tablesorter from the table (v2.3.2; <span class="version updated">v2.16</span>).
5641 <div class="collapsible">
5642 <pre class="prettyprint lang-js">// Remove tablesorter and all classes
5643 $("table").trigger("destroy");
5644
5645 // Remove tablesorter and all classes but the "tablesorter" class on the table
5646 // callback is a function
5647 $("table").trigger("destroy", [false, callback]);</pre></div>
5648 </td>
5649 <td></td>
5650 </tr>
5651
5652 <tr id="refreshwidgets">
5653 <td><a href="#" class="permalink">refreshWidgets</a></td>
5654 <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 (v2.4; <span class="verison updated">v2.19.0</span>).
5655 <div class="collapsible"><br>
5656 Trigger this method using either of the following methods (they are equivalent):
5657 <pre class="prettyprint lang-js">// trigger a refresh widget event
5658 $('table').trigger('refreshWidgets', [doAll, dontapply]);
5659
5660 // Use the API directly
5661 $.tablesorter.refreshWidgets(table, doAll, dontapply)</pre>
5662 <ul>
5663 <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>
5664 <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>
5665 <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>
5666 </ul>
5667 </div>
5668 </td>
5669 <td><a href="example-apply-widget.html">Example</a></td>
5670 </tr>
5671 </tbody>
5672
5673 <!-- non-sorting tbody -->
5674 <tbody id="methods-widgets" class="tablesorter-infoOnly">
5675 <tr><th colspan="3">Widget Methods</th></tr>
5676 </tbody>
5677
5678 <tbody>
5679 <tr id="search">
5680 <td><a href="#" class="permalink">search</a></td>
5681 <td>filter: Trigger the filter widget to update the search from current inputs and/or selections (v2.4; <span class="version updated">v2.15</span>).
5682 <div class="collapsible">
5683 This first method sends an array with the search strings to the filter widget.<pre class="prettyprint lang-js">$(function() {
5684 // apply "2?%" filter to the fifth column (zero-based index)
5685 var columns = [];
5686 columns[4] = '2?%'; // or define the array this way [ '', '', '', '', '2?%' ]
5687 $('table').trigger('search', [columns]);
5688 });</pre>
5689 or, directly add the search string to the filter input as follows:<pre class="prettyprint lang-js">$(function() {
5690 // apply "2?%" filter to the fifth column (zero-based index)
5691 $('table').find('input.tablesorter-filter').eq(4).val('2?%');
5692 $('table').trigger('search', false); // add a false flag to skip the search delay
5693 });</pre>
5694 In <span class="version updated">v2.15</span>, one additional parameter can be added to the array to perform an &quot;any-match&quot; of the table; <span class="label label-warning">Warning!</span> please note that if no external input (with a <code>data-column=&quot;all&quot;</code> is attached using <a href="#function-bindsearch"><code>bindSearch</code></a> function) is visible, the user will not know that a filter has been applied. <pre class="prettyprint lang-js">// in a table with 4 columns; set the 5th parameter to any-match
5695 $('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in any column</pre>
5696 </div>
5697 </td>
5698 <td></td>
5699 </tr>
5700
5701 <tr id="filterreset">
5702 <td><a href="#" class="permalink">filterReset</a></td>
5703 <td>filter: Trigger the filter widget to reset the search criteria (v2.7.7).
5704 <div class="collapsible"><br>
5705 If you are using the <code>filter_formatter</code> option to add custom input elements, this function may not work on those columns. Please refer to the <code>filter_formatter</code> section for more details.
5706 <pre class="prettyprint lang-js">$(function() {
5707 // this is the same code that the "filter_reset" element runs to clear out the filters.
5708 $('button').click(function() {
5709 $('table').trigger('filterReset');
5710 return false;
5711 });</pre>
5712 This method is used by the <a href="#widget-filter-reset"><code>filter_reset</code> option</a> when defined.
5713 </div>
5714 </td>
5715 <td><a href="example-widget-filter.html">Example</a></td>
5716 </tr>
5717
5718 <tr id="filterandsortreset">
5719 <td><a href="#" class="permalink">filterAndSortReset</a></td>
5720 <td>filter: Trigger the filter widget to reset the sort &amp; reset the search criteria (<span class="version">v2.28.7</span>).
5721 <div class="collapsible">
5722 <p>
5723 This combination reset was added to prevent issues with the widgets not being updated after a combination of <a href="#filterreset"><code>filterReset</code></a> and <a href="#sortreset"><code>sortReset</code></a> due to internal timers preventing multiple widget applications in a row.
5724 </p>
5725 This method does not include a callback parameter similiar to the <code>sortReset</code> method.
5726 <pre class="prettyprint lang-js">$(function() {
5727 $('button').click(function() {
5728 $('table').trigger('filterAndSortReset');
5729 return false;
5730 });</pre>
5731 </div>
5732 </td>
5733 <td></td>
5734 </tr>
5735
5736 <tr id="filterresetsaved">
5737 <td><a href="#" class="permalink">filterResetSaved</a></td>
5738 <td>filter: Make the filter widget reset any saved searches (<span class="version">v2.25.6</span>).
5739 <div class="collapsible"><br>
5740 Use this as follows:
5741 <pre class="prettyprint lang-js">$(function() {
5742 // this is the same code that the "filter_reset" element runs to clear out the filters.
5743 $('button').click(function() {
5744 $('#myTable').trigger('filterResetSaved');
5745 return false;
5746 });</pre>
5747 This is the equivalent of executing this function:
5748 <pre class="prettyprint lang-js">// clear the current table stored filters
5749 $.tablesorter.storage( $('#myTable'), 'tablesorter-filters', '' );</pre>
5750 </div>
5751 </td>
5752 <td><a href="example-widget-filter.html">Example</a></td>
5753 </tr>
5754
5755 <tr id="savesortreset">
5756 <td><a href="#" class="permalink">saveSortReset</a></td>
5757 <td>Trigger the saveSort widget to clear any saved sorts for that specific table (v2.7.11).
5758 <div class="collapsible">
5759 <pre class="prettyprint lang-js">$(function() {
5760 $('button').click(function() {
5761 $('table').trigger('saveSortReset');
5762 return false;
5763 });
5764 });</pre></div>
5765 </td>
5766 <td></td>
5767 </tr>
5768 </tbody>
5769
5770 <!-- non-sorting tbody -->
5771 <tbody id="methods-pager" class="tablesorter-infoOnly">
5772 <tr><th colspan="3">Pager Methods</th></tr>
5773 </tbody>
5774
5775 <tbody>
5776 <tr id="pagesize">
5777 <td><a href="#" class="permalink">pageSize</a></td>
5778 <td>Trigger the pager to change the page size (v2.7.4; <span class="version updated">v2.24.0</span>).
5779 <div class="collapsible">
5780 <pre class="prettyprint lang-js">$(function() {
5781 $('table').trigger('pageSize', 15);
5782 });</pre>
5783 In <span class="version updated">v2.24.0</span>, this option will now accept "all" as a setting, and in turn display all rows.
5784 </div>
5785 </td>
5786 <td></td>
5787 </tr>
5788 <tr id="pageset">
5789 <td><a href="#" class="permalink">pageSet</a></td>
5790 <td>Trigger the pager to change the current page (v2.7.7).
5791 <div class="collapsible">
5792 <br>
5793 If no value is passed, the pager will reset to page 1; otherwise, pass a "one-based" index of the desired page
5794 <pre class="prettyprint lang-js">$(function() {
5795 $('table').trigger('pageSet', 3); // pass a one-based index
5796 });</pre></div>
5797 </td>
5798 <td></td>
5799 </tr>
5800 <tr id="pageandsize">
5801 <td><a href="#" class="permalink">pageAndSize</a></td>
5802 <td>Trigger the pager to change the current page &amp; size (<span class="version">v2.19.0</span>; ; <span class="version updated">v2.24.0</span>).
5803 <div class="collapsible">
5804 <br>
5805 If no value is passed, the pager will reset to page 1 with the original pager size setting; otherwise, pass a "one-based" index of the desired page and the pager size as an array
5806 <pre class="prettyprint lang-js">$(function() {
5807 $('table').trigger('pageAndSize', [ 2, 20 ]); // pass a one-based page index & page size
5808 });</pre>
5809 In <span class="version updated">v2.24.0</span>, this option will now accept "all" as a page size setting, and in turn display all rows; the page number will be force to page one.
5810 </div>
5811 </td>
5812 <td></td>
5813 </tr>
5814 <tr id="pagerupdate">
5815 <td><a href="#" class="permalink">pagerUpdate</a></td>
5816 <td>Force the pager to update the table with the current settings (<span class="version">v2.19.0</span>).
5817 <div class="collapsible">
5818 <br>
5819 If there is a need, this method will force the (ajax and non-ajax) pager to update. Use it as follows:
5820 <pre class="prettyprint lang-js">$(function() {
5821 $('table').trigger('pagerUpdate');
5822 });</pre>
5823 Or, if you need, you can optionally pass a new page number:
5824 <pre class="prettyprint lang-js">$(function() {
5825 $('table').trigger('pagerUpdate', 3); // update and set to page 3
5826 });</pre>
5827 </div>
5828 </td>
5829 <td></td>
5830 </tr>
5831
5832 <tr id="destroypager">
5833 <td><a href="#" class="permalink">destroyPager</a></td>
5834 <td>Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16; <span class="version updated">v2.23.0</span>).
5835 <div class="collapsible">
5836 <p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>destroy.pager</code> to <code>destroyPager</code> because of issues with unique namespacing.</p>
5837 <pre class="prettyprint lang-js">$(function() {
5838 $('table').trigger('destroyPager');
5839 });</pre>
5840 The only way to restore the pager addon is to re-initialize the pager addon:
5841 <br>
5842 <pre class="prettyprint lang-js">$(function() {
5843 $('table').tablesorterPager(pagerOptions);
5844 });</pre></div>
5845 </td>
5846 <td><a href="example-pager.html">Example</a></td>
5847 </tr>
5848
5849 <tr id="disablepager">
5850 <td><a href="#" class="permalink">disablePager</a></td>
5851 <td>This method will put the pager into a disabled state (v2.0.21.2; <span class="version updated">v2.23.0</span>).
5852 <div class="collapsible">
5853 <p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>disable.pager</code> to <code>disablePager</code> because of issues with unique namespacing.</p>
5854 The disabled state will reveal all table rows and disable, but not hide, pager controls.
5855 <br>
5856 <pre class="prettyprint lang-js">$(function() {
5857 $('table').trigger('disablePager');
5858 });</pre></div>
5859 </td>
5860 <td><a href="example-pager.html">Example</a></td>
5861 </tr>
5862
5863 <tr id="enablepager">
5864 <td><a href="#" class="permalink">enablePager</a></td>
5865 <td>This method will re-enable the pager, but only from the disabled state (v2.0.21.2; <span class="version updated">v2.23.0</span>).
5866 <div class="collapsible">
5867 <p>In <span class="version updated">v2.23.0</span>, this method was changed from <code>enable.pager</code> to <code>enablePager</code> because of issues with unique namespacing.</p>
5868 <pre class="prettyprint lang-js">$(function() {
5869 $('table').trigger('enablePager');
5870 });</pre></div>
5871 </td>
5872 <td><a href="example-pager.html">Example</a></td>
5873 </tr>
5874
5875 </tbody>
5876
5877 </table>
5878
5879 <a id="events"></a>
5880 <h1>Events</h1>
5881
5882 <div class="tip">
5883 <p></p>
5884 tablesorter has some methods available to allow updating, resorting or applying widgets to a table after it has been initialized.
5885 <br>
5886 <span class="label label-info">TIP!</span> 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.
5887 </div>
5888
5889 <table id="event" class="tablesorter-blue options" data-sortlist="[[0,0]]">
5890 <thead>
5891 <tr>
5892 <th>Event</th>
5893 <th class="sorter-false">Description</th>
5894 <th class="sorter-false">Link</th>
5895 </tr>
5896 </thead>
5897 <tbody>
5898
5899 <tr id="tablesorter-initialized">
5900 <td><a href="#" class="permalink">tablesorter-initialized</a></td>
5901 <td>This event fires when tablesorter has completed initialization. (v2.2).
5902 <div class="collapsible">
5903 <pre class="prettyprint lang-js">$(function() {
5904
5905 // bind to initialized event BEFORE initializing tablesorter*
5906 $("table")
5907 .bind("tablesorter-initialized",function(e, table) {
5908 // do something after tablesorter has initialized
5909 });
5910
5911 // initialize the tablesorter plugin
5912 $("table").tablesorter({
5913 // this is equivalent to the above bind method
5914 initialized : function(table) {
5915 // do something after tablesorter has initialized
5916 }
5917 });
5918
5919 });</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
5920 </td>
5921 <td></td>
5922 </tr>
5923
5924 <tr id="sortbegin">
5925 <td><a href="#" class="permalink">sortBegin</a></td>
5926 <td>This event fires immediately before tablesorter begins resorting the table.
5927 <div class="collapsible">
5928 <pre class="prettyprint lang-js">$(function() {
5929
5930 // initialize the tablesorter plugin
5931 $("table").tablesorter();
5932
5933 // bind to sort events
5934 $("table").bind("sortBegin",function(e, table) {
5935 // do something crazy!
5936 });
5937 });</pre></div>
5938 </td>
5939 <td></td>
5940 </tr>
5941
5942 <tr id="sortstart">
5943 <td><a href="#" class="permalink">sortStart</a></td>
5944 <td>This event fires immediately after the tablesorter header has been clicked, initializing a resort.
5945 <div class="collapsible">
5946 <pre class="prettyprint lang-js">$(function() {
5947
5948 // initialize the tablesorter plugin
5949 $("table").tablesorter();
5950
5951 // bind to sort events
5952 $("table")
5953 .bind("sortStart",function(e, table) {
5954 $("#overlay").show();
5955 })
5956 .bind("sortEnd",function(e, table) {
5957 $("#overlay").hide();
5958 });
5959 });</pre></div>
5960 </td>
5961 <td><a href="example-triggers.html">Example</a></td>
5962 </tr>
5963
5964 <tr id="sortend">
5965 <td><a href="#" class="permalink">sortEnd</a></td>
5966 <td>This event fires when tablesorter has completed resorting the table.
5967 <div class="collapsible">
5968 <pre class="prettyprint lang-js">$(function() {
5969
5970 // initialize the tablesorter plugin
5971 $("table").tablesorter();
5972
5973 // bind to sort events
5974 $("table")
5975 .bind("sortStart",function(e, table) {
5976 $("#overlay").show();
5977 })
5978 .bind("sortEnd",function(e, table) {
5979 $("#overlay").hide();
5980 });
5981 });</pre></div>
5982 </td>
5983 <td><a href="example-triggers.html">Example</a></td>
5984 </tr>
5985
5986 <tr id="updatecomplete">
5987 <td><a href="#" class="permalink">updateComplete</a></td>
5988 <td>This event fires after tablesorter has completed updating (v2.3.9).
5989 <div class="collapsible">
5990 This occurs after an "update", "updateAll", "updateCell" or "addRows" method was called, but before any callback functions are executed.
5991 <pre class="prettyprint lang-js">$(function() {
5992
5993 // initialize the tablesorter plugin
5994 $('table')
5995 .tablesorter()
5996 // bind to sort events
5997
5998 .bind('updateComplete', function(e, table) {
5999 // do something after the table has been altered;
6000 });
6001
6002 });</pre></div>
6003 </td>
6004 <td></td>
6005 </tr>
6006
6007 <tr id="tablesorterready">
6008 <td><a href="#" class="permalink">tablesorter-ready</a></td>
6009 <td>This event fires after tablesorter has complete applying all widgets and is ready for its next action (<span class="version">v2.24.0</span>).
6010 <div class="collapsible">
6011 This event occurs after an "updateComplete" and "pagerComplete" event. There may be some other table interaction if a widget includes any <code>setTimeout</code> functions.
6012 <pre class="prettyprint lang-js">$(function() {
6013
6014 // initialize the tablesorter plugin
6015 $('table')
6016 .tablesorter()
6017 // bind to sort events
6018
6019 .bind('tablesorter-ready', function(e, table) {
6020 // do something after tablesorter has finished interacting with the table;
6021 });
6022
6023 });</pre></div>
6024 </td>
6025 <td></td>
6026 </tr>
6027
6028 <tr id="refreshcomplete">
6029 <td><a href="#" class="permalink">refreshComplete</a></td>
6030 <td>This event fires after tablesorter has completed executing the <a href="#refreshwidgets">refreshWidget</a> method (<span class="version">v2.19.0</span>)
6031 <div class="collapsible">
6032 <br>
6033 Use it as follows:
6034 <pre class="prettyprint lang-js">$(function() {
6035
6036 // initialize the tablesorter plugin
6037 $('table')
6038 .tablesorter()
6039 // bind to sort events
6040 .bind('refreshComplete', function(e, table) {
6041 // do something after the 'refreshWidgets' has refreshed
6042 });
6043
6044 });</pre></div>
6045 </td>
6046 <td></td>
6047 </tr>
6048
6049 </tbody>
6050
6051 <!-- non-sorting tbody -->
6052 <tbody id="events-widgets" class="tablesorter-infoOnly">
6053 <tr><th colspan="3">Widget Events</th></tr>
6054 </tbody>
6055
6056 <!-- widget events -->
6057 <tbody>
6058
6059 <tr id="filterinit">
6060 <td><a href="#" class="permalink">filterInit</a></td>
6061 <td>Event triggered when the filter widget has finished initializing (v2.4).
6062 <div class="collapsible"><br>
6063 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-js">$(function() {
6064 $('table')
6065
6066 // bind to filter initialized event BEFORE initializing tablesorter*
6067 .bind('filterInit', function(event, config) {
6068 $(this).find('tr.tablesorter-filter-row').addClass('fred');
6069 })
6070
6071 // initialize the sorter
6072 .tablesorter({
6073 widgets : ['filter']
6074 });
6075
6076 });</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
6077 </td>
6078 <td><a href="example-option-show-processing.html">Example</a></td>
6079 </tr>
6080
6081 <tr id="filterstart">
6082 <td><a href="#" class="permalink">filterStart</a></td>
6083 <td>Event triggered when the filter widget has started processing the search (v2.4).
6084 <div class="collapsible"><br>
6085 You can use this event to do something like add a class to the filter row. Use it as follows:<pre class="prettyprint lang-js">$(function() {
6086 $('table').bind('filterStart', function(event, filters) {
6087 // filters contains an array of the current filters
6088 $(this).find('tr.tablesorter-filter-row').addClass('filtering');
6089 });
6090 });</pre></div>
6091 </td>
6092 <td><a href="example-option-show-processing.html">Example</a></td>
6093 </tr>
6094
6095 <tr id="filterend">
6096 <td><a href="#" class="permalink">filterEnd</a></td>
6097 <td>Event triggered when the filter widget has finished processing the search (v2.4).
6098 <div class="collapsible"><br>
6099 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-js">$(function() {
6100 $('table').bind('filterEnd', function(event, config) {
6101 $(this).find('tr.tablesorter-filter-row').removeClass('filtering');
6102 });
6103 });</pre></div>
6104 </td>
6105 <td><a href="example-option-show-processing.html">Example</a></td>
6106 </tr>
6107
6108 <tr id="stickyheadersinit">
6109 <td><a href="#" class="permalink">stickyHeadersInit</a></td>
6110 <td>Event triggered when the stickyHeader widget has finished initializing (<span class="version">v2.10.4</span>).
6111 <div class="collapsible"><br>
6112 You can use this event to do something like modify content within the sticky header:<pre class="prettyprint lang-js">$(function() {
6113 $('table')
6114 // bind to the init event BEFORE initializing tablesorter*
6115 .bind('stickyHeadersInit', function() {
6116 // this.config.widgetOptions.$sticky contains the entire sticky header table
6117 this.config.widgetOptions.$sticky.find('tr.tablesorter-headerRow').addClass('sticky-styling');
6118 })
6119
6120 // initialize the tablesorter plugin
6121 .tablesorter({
6122 widgets : ['stickyHeaders']
6123 });
6124
6125 });</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
6126 </td>
6127 <td></td>
6128 </tr>
6129
6130 <tr id="widgetremoveend">
6131 <td><a href="#" class="permalink">widgetRemoveEnd</a></td>
6132 <td>Event triggered after <em>any</em> widget has finished being removed (<span class="version">v2.29.0</span>).
6133 <div class="collapsible"><br>
6134 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-js">$(function() {
6135 $('table').bind('widgetRemoveEnd', function(event, table) {
6136 // do something after widget was removed
6137 });
6138 });</pre>
6139 This method does not include data on which widget was removed.
6140 </div>
6141 </td>
6142 <td><a href="example-option-show-processing.html">Example</a></td>
6143 </tr>
6144
6145 </tbody>
6146
6147 <!-- non-sorting tbody -->
6148 <tbody id="events-pager" class="tablesorter-infoOnly">
6149 <tr><th colspan="3">Pager Events</th></tr>
6150 </tbody>
6151
6152 <!-- Pager addon events -->
6153 <tbody>
6154 <tr id="pagerchange">
6155 <td><a href="#" class="permalink">pagerChange</a></td>
6156 <td>This event fires when the pager plugin begins to render the table on the currently selected page. (v2.0.7).
6157 <div class="collapsible">
6158 <pre class="prettyprint lang-js">$(function() {
6159
6160 // initialize the sorter
6161 $("table")
6162 .tablesorter()
6163
6164 // initialize the pager plugin
6165 .tablesorterPager({
6166 container: $("#pager")
6167 })
6168
6169 // bind to pager events
6170 .bind('pagerChange pagerComplete', function(event, options) {
6171 // options = table.config.pager (pager addon)
6172 // options = table.config (pager widget) - so use options.pager.page below
6173 // this.totalPages contains the total number of pages (this = table)
6174 $('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
6175 });
6176
6177 });</pre></div>
6178 </td>
6179 <td><a href="example-pager.html">Example</a></td>
6180 </tr>
6181
6182 <tr id="pagercomplete">
6183 <td><a href="#" class="permalink">pagerComplete</a></td>
6184 <td>This event fires when the pager plugin has completed initialization (<span class="version">v2.18.1</span>), and its render of the table on the currently selected page. (v2.0.7).
6185 <div class="collapsible">
6186 <br>
6187 <span class="label label-info">Note</span> In <span class="version">v2.18.1</span>, the "pagerComplete" event also fires off immediately after pager initialization.<br>
6188 <br>
6189 <pre class="prettyprint lang-js">$(function() {
6190
6191 // initialize the sorter
6192 $("table")
6193 .tablesorter()
6194
6195 // initialize the pager plugin
6196 .tablesorterPager({
6197 container: $("#pager")
6198 })
6199
6200 // bind to pager events
6201 .bind('pagerChange pagerComplete', function(event, options) {
6202 // options = table.config.pager (pager addon)
6203 // options = table.config (pager widget) - so use options.pager.page below
6204 // c.totalPages contains the total number of pages
6205 $('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
6206 });
6207
6208 });</pre></div>
6209 </td>
6210 <td><a href="example-pager.html">Example</a></td>
6211 </tr>
6212
6213 <tr id="pagerbeforeinitialized">
6214 <td><a href="#" class="permalink">pagerBeforeInitialized</a></td>
6215 <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 (v2.4.4).
6216 <div class="collapsible">
6217 <pre class="prettyprint lang-js">$(function() {
6218
6219 $("table")
6220
6221 // bind to pager initialized event BEFORE calling the ADDON
6222 // or BEFORE initializing tablesorter when using the pager WIDGET*
6223 .bind('pagerBeforeInitialized', function(event, options) {
6224 // options = table.config.pager (pager addon)
6225 // options = table.config (pager widget)
6226
6227 // event = event object; options = pager options
6228 })
6229
6230 // initialize the sorter
6231 .tablesorter()
6232
6233 // initialize the pager plugin
6234 .tablesorterPager({
6235 container: $("#pager")
6236 });
6237
6238 });</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
6239 </td>
6240 <td></td>
6241 </tr>
6242
6243 <tr id="pagerinitialized">
6244 <td><a href="#" class="permalink">pagerInitialized</a></td>
6245 <td>This event fires when the pager plugin has completed initialization (v2.4.4).
6246 <div class="collapsible">
6247 <pre class="prettyprint lang-js">$(function() {
6248
6249 $("table")
6250
6251 // bind to pager initialized event BEFORE calling the ADDON
6252 // or BEFORE initializing tablesorter when using the pager WIDGET*
6253 .bind('pagerInitialized', function(event, options) {
6254 // options = table.config.pager (pager addon)
6255 // options = table.config (pager widget) - so use options.pager.page below
6256 // c.totalPages contains the total number of pages
6257 $('#display').html( e.type + " event triggered, now on page " + (options.page + 1) );
6258 })
6259
6260 // initialize the sorter
6261 .tablesorter()
6262
6263 // initialize the pager plugin
6264 .tablesorterPager({
6265 container: $("#pager")
6266 });
6267
6268 });</pre><small>* Note: bind to all initialization events before initializing tablesorter; because most of the time, if bound after, the events will fire before the binding occurs</small>.</div>
6269 </td>
6270 <td><a href="example-pager.html">Example</a></td>
6271 </tr>
6272
6273 <tr id="pagemoved">
6274 <td><a href="#" class="permalink">pageMoved</a></td>
6275 <td>This event fires when the pager plugin begins to change to the selected page (v2.4.4).
6276 <div class="collapsible">
6277 This event may fire before the <code>pagerComplete</code> event when ajax processing is involved, or after the <code>pagerComplete</code> on normal use.
6278 See <a href="https://github.com/Mottie/tablesorter/pull/153">issue #153</a>.
6279 <pre class="prettyprint lang-js">$(function() {
6280
6281 // initialize the sorter
6282 $("table")
6283 .tablesorter()
6284
6285 // initialize the pager plugin
6286 .tablesorterPager({
6287 container: $("#pager")
6288 })
6289
6290 // bind to pager events
6291 .bind('pageMoved', function(event, options) {
6292 // options = table.config.pager (pager addon)
6293 // options = table.config (pager widget) - so use options.pager.page below
6294 // c.totalPages contains the total number of pages
6295 $('#display').html( event.type + " event triggered, now on page " + (options.page + 1) );
6296 });
6297
6298 });</pre></div>
6299 </td>
6300 <td><a href="example-pager.html">Example</a></td>
6301 </tr>
6302
6303 </tbody>
6304 </table>
6305
6306 <a id="api"></a>
6307 <h1>Tablesorter API</h1>
6308
6309 <div class="tip">
6310 tablesorter has some useful internal variables &amp; functions available through the API which can be used in custom coding, parsers and/or widgets.<br>
6311
6312 <h4>Variables</h4>
6313 <span class="label label-info">TIP!</span> Click on the link in the variable 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.
6314 </div>
6315
6316 <table class="api tablesorter-blue" data-sortlist="[[0,0]]">
6317 <thead>
6318 <tr>
6319 <th class="setwidth">Variable</th>
6320 <th>Type</th>
6321 <th class="sorter-false">Description</th>
6322 <th class="sorter-false">Link</th>
6323 </tr>
6324 </thead>
6325
6326 <tbody>
6327 <tr id="variable-defaults">
6328 <td><a href="#" class="permalink">$.tablesorter.defaults</a></td>
6329 <td>Object</td>
6330 <td>This object contains all of the default settings shown in the <a href="#Configuration">configuration</a> section.
6331 <div class="collapsible">
6332 <p>
6333 Changing a defaults will cause all tables using the code to alter its default behavior without needing to include the options while initializing. For example, changing the default theme will cause all tables to use the new theme (make sure to include the css!).
6334 </p>
6335 <span class="label warning">Note</span>: If you wish to modify this object, make sure to either target the setting directly: <pre class="prettyprint lang-js">
6336 // set the default directly
6337 $.tablesorter.defaults.theme = 'myCustomTheme';</pre>
6338 Or use jQuery extend (include <code>true</code> parameter for <a href="http://api.jquery.com/jQuery.extend/#jQuery-extend-deep-target-object1-objectN">more depth</a>): <pre class="prettyprint lang-js">
6339 // Extend the object. Use `true` for more than one level of depth
6340 $.extend( true, $.tablesorter.defaults, {
6341 theme: 'myCustomTheme',
6342 widgets: ['zebra', 'filter'],
6343 widgetOptions: {
6344 filter_placeholder: {
6345 search: 'Find in column...',
6346 select: 'Choose an option'
6347 },
6348 zebra: [ 'row-even', 'row-odd' ]
6349 }
6350 });</pre>
6351 If you don't use one of the above methods, the other default settings will be removed and cause unexpected issues.
6352 </div>
6353 </td>
6354 <td></td>
6355 </tr>
6356
6357 <tr id="variable-parsers">
6358 <td><a href="#" class="permalink">$.tablesorter.parsers</a></td>
6359 <td>Array</td>
6360 <td>This is an array of all parser objects added using the <a href="#function-addparser"><code>addParser</code></a> function.
6361 <div class="collapsible">
6362 <br>
6363 If a specific parser needs to be retreived from this array, use the <a href="#function-getparserbyid"><code>getParserById</code></a> function.
6364 </div>
6365 </td>
6366 <td></td>
6367 </tr>
6368
6369 <tr id="variable-themes">
6370 <td><span class="permalink">$.tablesorter.themes</span></td>
6371 <td>Object</td>
6372 <td>This is an object containing a list of specific class names to be applied to table elements. Please see the widget <a href="#widget-uitheme"><code>uitheme</code></a> option for more details. </td>
6373 <td></td>
6374 </tr>
6375
6376 <tr id="variable-widgets">
6377 <td><a href="#" class="permalink">$.tablesorter.widgets</a></td>
6378 <td>Array</td>
6379 <td>This is an array of all widget objects added using the <a href="#function-addwidget"><code>addWidget</code></a> function.
6380 <div class="collapsible">
6381 <br>
6382 If a specific widget needs to be retreived from this array, use the <a href="#function-getwidgetbyid"><code>getWidgetById</code></a> function.
6383 </div>
6384 </td>
6385 <td></td>
6386 </tr>
6387
6388 <tr id="variable-language">
6389 <td><a href="#" class="permalink">$.tablesorter.language</a></td>
6390 <td>Object</td>
6391 <td>This object contains the phrases (in English by default) added to the <code>aria-label</code> on each header column (<span class="version updated">v2.24.4</span>).
6392 <div class="collapsible">
6393 <p>In <span class="version updated">v2.24.4</span>, <code>sortDisabled</code> was added to the language settings. It is added to disabled columns which may have a sort applied; so, instead of "nextAsc", "nextDesc" or "nextNone" being appended to the sort message, the "sortDisabled" content is added.</p>
6394 This is how the object is set up:
6395 <pre class="prettyprint lang-js">$.tablesorter.language = {
6396 sortAsc : 'Ascending sort applied, ',
6397 sortDesc : 'Descending sort applied, ',
6398 sortNone : 'No sort applied, ',
6399 sortDisabled : 'sorting is disabled', // added v2.24.4
6400 nextAsc : 'activate to apply an ascending sort',
6401 nextDesc : 'activate to apply a descending sort',
6402 nextNone : 'activate to remove the sort'
6403 };</pre>
6404 So, as an example, in the following situation:
6405 <ul>
6406 <li>A table header is named &quot;Account #&quot;</li>
6407 <li>This column has an ascending sort applied</li>
6408 <li>The next click on the header will be a descending sort, which means:
6409 <ul>
6410 <li><code>sortInitialOrder</code> option has its default setting; so the sort order will switch from ascending to descending on the second click.</li>
6411 <li>No <code>lockedOrder</code> is set within the <code>headers</code> option</li>
6412 </ul>
6413 </li>
6414 </ul>
6415 Then the label will be built as follows:
6416 <pre class="prettyprint lang-js">// &quot;Header Name&quot; + $.tablesorter.language.sortAsc + $.tablesorter.language.nextDesc
6417 &quot;Account #: Ascending sort applied, activate to apply a descending sort&quot;</pre>
6418 If the next click were to reset the sort (<code>sortReset</code> applied), then the message would use <code>$.tablesorter.language.nextNone</code>.<br>
6419 <br>
6420 In <span class="version updated">v2.24.4</span>, if sorting is disabled but the column has a sort applied, the label will be built as follows:
6421 <pre class="prettyprint lang-js">// &quot;Header Name&quot; + $.tablesorter.language.sortDesc + $.tablesorter.language.sortDisabled
6422 &quot;Account #: Descending sort applied, sorting is disabled&quot;</pre>
6423 Use this variable to change the language as follows:
6424 <pre class="prettyprint lang-js">$(function() {
6425
6426 $.tablesorter.language = {
6427 sortAsc : 'sorting from a to z, ',
6428 sortDesc : 'sorting from z to a, ',
6429 sortNone : 'not sorted, but ',
6430 sortDisabled : 'sorting is disabled',
6431 nextAsc : 'click to sort from a to z',
6432 nextDesc : 'click to sort from z to a',
6433 nextNone : 'click to clear the sort'
6434 }
6435 $('table').tablesorter();
6436 });</pre>
6437 </div>
6438 </td>
6439 <td>
6440 <a href="example-widget-header-titles.html">1</a>
6441 <a href="example-widget-toggle-tablesorter.html">2</a>
6442 </td>
6443 </tr>
6444 <tr id="variable-instanceMethods">
6445 <td><a href="#" class="permalink">$.tablesorter.instanceMethods</a></td>
6446 <td>Object</td>
6447 <td>This variable contains all instance methods of the config object. Added using <a href="#function-addInstanceMethods"><code>addInstanceMethods</code></a> function before table initialization (<span class="version">v2.21.0</span>).
6448 <div class="collapsible">
6449 <br>
6450 <pre class="prettyprint lang-js">$.tablesorter.addInstanceMethods({
6451 columnSum: function(colNumber) {
6452 var sum = 0, tbodyIndex, normalizedRows, rowIndex;
6453 // `this` refers to config object
6454 for (tbodyIndex = 0; tbodyIndex &lt; this.$tbodies.length; ++tbodyIndex) {
6455 normalizedRows = this.cache[tbodyIndex].normalized;
6456 for (rowIndex = 0; rowIndex &lt; normalizedRows.length; ++rowIndex) {
6457 sum += normalizedRows[rowIndex][colNumber];
6458 }
6459 }
6460 return sum;
6461 },
6462 columnMean: function(colNumber) {
6463 return this.columnSum(colNumber) / this.totalRows;
6464 },
6465 });
6466
6467 $('table').tablesorter();
6468 c = $('table')[0].config;
6469 console.log('sum of third column: ' + c.columnSum(2));
6470 console.log('mean of third column: ' + c.columnMean(2));</pre>
6471 </div>
6472 </td>
6473 <td></td>
6474 </tr>
6475
6476 </tbody>
6477
6478 <!-- non-sorting tbody -->
6479 <tbody id="functions-core" class="tablesorter-infoOnly">
6480 <tr id="config">
6481 <th class="nobold"><a href="#" class="permalink">core</a></th>
6482 <th></th>
6483 <th class="nobold">Access the table configuration variables (<code>config</code>) using any of these methods:
6484 <div class="collapsible">
6485 <br>
6486 <pre class="prettyprint lang-js">// pure js, get the first table (zero index)
6487 var config = document.getElementsByTagName('table')[0].config;
6488 // or by table ID
6489 var config = document.getElementById('mytable').config;
6490
6491 // using jQuery, get first table (zero index)
6492 var config = $('table')[0].config;
6493 // or from the jQuery data
6494 var config = $('#mytable').data('tablesorter');
6495 </pre>
6496 </div>
6497 </th>
6498 <th></th>
6499 </tr>
6500 </tbody>
6501
6502 <tbody>
6503
6504 <tr id="variable-cache">
6505 <td><a href="#" class="permalink">config.cache</a></td>
6506 <td>Object</td>
6507 <td>Internal list of table contents (<span class="version">v2.0.18</span>; <span class="version updated">v2.20.0</span> )
6508 <div class="collapsible">
6509 <br>
6510 This object contains the following:<br>
6511 <ul>
6512 <li>tbody index (<strong>non-info block only</strong>, indexing now matches the <a href="#variable-tbodies"><code>config.$tbodies</code></a> variable; <span class="version updated">v2.20.0</span>)
6513 <ul>
6514 <li><code>colMax</code>
6515 <ul>
6516 <li>This contains an array of the absolute value maximum numerical value for each "numerically" parsed column per tbody.</li>
6517 <li>Text columns will have an undefined value in this array.</li>
6518 <li>Used when determining how to sort text within a numeric column.</li>
6519 <li>Access it as follows: <pre class="prettyprint lang-js">// $('table')[0].config.cache[tbodyIndex].colMax[column];
6520 // try this in the console for this page:
6521 $('.tablesorter')[0].config.cache[0].colMax;
6522 // result: [undefined &#x00d7; 3, 45, 153.19, 44.7, 100.9, 1169133120000]</pre></li>
6523 </ul>
6524 </li>
6525 <li><code>normalized</code>
6526 <ul>
6527 <li>This contains an array of indexed table rows.</li>
6528 <li>Within each row is an array of extracted, then parsed table contents for each column (plus one extra value; see the next comment).</li>
6529 <li>It is important to note that the last value in the column array is <del>the original row index value</del>. This is used when resetting a column sort to its original unsorted order.</li>
6530 <li>In <span class="version updated">v2.19.1</span>, the <code>raw</code> unparsed data was added to the row data.</li>
6531 <li>In <span class="version updated">v2.16.0</span>, the last value in the column array is now an object which contains a jquery object of the row, index of the original unsorted order and a child array which contains raw html from any associated child row
6532 <pre class="prettyprint lang-js">// $('table')[0].config.cache[tbodyIndex].normalized[row][column]
6533 // try this in the console for this page:
6534 $('.tablesorter')[0].config.cache[0].normalized[0];
6535 /* result: ["a1", "bruce", "almighty", 45, 153.19, 44.7, 77, 979830720000, {
6536 $row : jQuery.fn.jQuery.init[1], // row (jQuery object)
6537 child : [], // child row raw html, if any
6538 // raw unparsed data from the table cells - added v2.19.1
6539 raw : ["A1", "Bruce", "Almighty", "45", "$153.19", "44.7%", "+77", "Jan 18, 2001 9:12 AM"],
6540 order : 3 // original row index (unsorted)
6541 }]
6542 */</pre>
6543 to specifically target the extra row data, use this method:
6544 <pre class="prettyprint lang-js">var config = $('.tablesorter')[0].config,
6545 dataIndex = config.columns, // number of columns within the table
6546 rowData = config.cache[tbodyIndex].normalized[row][ dataIndex ];</pre>
6547 </li>
6548 <li>Note that all text values will be in lower case if the <a href="#ignorecase"><code>ignoreCase</code></a> option is <code>true</code>.</li>
6549 <li>This internal normalized content is what is actually sorted for maximum performance.</li>
6550 </ul>
6551 </li>
6552 <li><code>row</code> (<span class="label label-danger">removed</span> in v2.16.0)
6553 <ul>
6554 <li>Well not removed, but moved into the row data, within the normalized section of the cache as described above.</li>
6555 <li><del>This contains an array of jQuery row objects</del>.</li>
6556 <li><del>These rows are never in sort order, and are used when updating the table after sorting the normalized content. The indexing of these rows is cross-referenced within the normalized values - the extra column value within the row array. Hopefully that makes sense</del>.</li>
6557 </ul>
6558 </li>
6559 </ul>
6560 </li>
6561 </ul>
6562 The <code>table.config.cache</code> variable is useful when writing widgets that need access to the parsed content.
6563 </div>
6564 </td>
6565 <td></td>
6566 </tr>
6567
6568 <tr id="variable-columns">
6569 <td><a href="#" class="permalink">config.columns</a></td>
6570 <td>Numeric</td>
6571 <td>Internal count of the number of table columns in the header (<span class="version">v2.12</span>)
6572 <div class="collapsible">
6573 <br>
6574 This number is stored as a length (one-based), and takes into account any <code>colspan</code> and <code>rowspan</code> within the table head.<br>
6575 <br>
6576 Note that the <code>table.config.columns</code> variable does not always correlate with the indexing of the headers stored within <a href="#variable-headers"><code>table.config.$headers</code></a> because of multiple rows and column or row spans.
6577 </div>
6578 </td>
6579 <td></td>
6580 </tr>
6581
6582 <tr id="variable-headercontent">
6583 <td><a href="#" class="permalink">config.headerContent</a></td>
6584 <td>Array</td>
6585 <td>Internal list of each header's starting HTML (as text) (v2.8)
6586 <div class="collapsible"><br>
6587 This HTML snapshot is taken using the <a href="#variable-headers"><code>$headers</code></a> jQuery object, and done before the <a href="#headertemplate"><code>headerTemplate</code></a> is applied and before the <a href="#onrendertemplate"><code>onRenderTemplate</code></a> and <a href="#onrenderheader"><code>onRenderHeader</code></a> callbacks are executed.<br>
6588 <br>
6589 This list is used by the <code>$.tablesorter.restoreHeaders</code> function to restore the table headers when the <a href="#destroy"><code>destroy</code></a> method is executed.
6590 </div>
6591 </td>
6592 <td></td>
6593 </tr>
6594
6595 <tr id="variable-headerlist">
6596 <td><a href="#" class="permalink">config.headerList</a></td>
6597 <td>Array</td>
6598 <td>Internal list of each header element as selected using jQuery selectors in the <a href="#selectorheaders"><code>selectorHeaders</code></a> option.
6599 <div class="collapsible">
6600 <br>
6601 This list contains DOM elements (not jQuery objects of each table header cell like the <a href="#variable-headers"><code>$headers</code></a> variable) and is how the original version of tablesorter stored these objects.
6602 <br>
6603 It is not used in the current version of tablesorter, and is only left in place for backwards compatibility with widgets written for the original tablesorter plugin.
6604 </div>
6605 </td>
6606 <td></td>
6607 </tr>
6608
6609 <tr id="parsers">
6610 <td><a href="#" class="permalink">config.parsers</a></td>
6611 <td>Array</td>
6612 <td>Internal list of all of the table's currently set parsers (objects copied from <a href="#variable-parsers"><code>$.tablesorter.parsers</code></a>). Here is a complete list of default parsers: (modified v2.18.0)
6613 <div class="collapsible">
6614 <br>
6615 <table class="info"><tbody>
6616 <tr><th><code>parser: false</code></th><td>disable parsing for this column (this also disables sorting & filtering for the column; <span class="version updated">v2.17.6</span>).</td></tr>
6617 <tr><th><code>sorter: false</code></th><td>disable sort for this column.</td></tr>
6618 <tr><th><code>sorter: &quot;text&quot;</code></th><td>Sort alpha-numerically.</td></tr>
6619 <tr><th><code>sorter: &quot;digit&quot;</code></th><td>Sort numerically.</td></tr>
6620 <tr><th><code>sorter: &quot;currency&quot;</code></th><td>Sort by currency value (supports "&#163;$&#8364;&#x00a4;&#x00a5;&#x00a2;").</td></tr>
6621 <tr><th><code>sorter: &quot;image&quot;</code></th><td>Sort by image alt value (see <a href="#imgattr"><code>imgAttr</code></a> option; added in v2.18.0).</td></tr>
6622 <tr><th><code>sorter: &quot;ipAddress&quot;</code></th><td>Sort by IP Address; <span class="label label-warning">Warning</span> This parser was moved to the <code>parser-network.js</code> file in <span class="version updated">v2.18.0</span>.</td></tr>
6623 <tr><th><code>sorter: &quot;url&quot;</code></th><td>Sort by url.</td></tr>
6624 <tr><th><code>sorter: &quot;isoDate&quot;</code></th><td>Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD; these formats can be followed by a time).</td></tr>
6625 <tr><th><code>sorter: &quot;percent&quot;</code></th><td>Sort by percent.</td></tr>
6626 <tr><th><code>sorter: &quot;usLongDate&quot;</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>
6627 <tr><th><code>sorter: &quot;shortDate&quot;</code></th><td>Sort by a shortened date (see <a href="#dateformat"><code>dateFormat</code></a>; these formats can also be followed by a time).</td></tr>
6628 <tr><th><code>sorter: &quot;time&quot;</code></th><td>Sort by time (23:59 or 12:59 pm).</td></tr>
6629 <tr><th><code>sorter: &quot;metadata&quot;</code></th><td>Sort by the sorter value in the metadata - requires the metadata plugin.</td></tr>
6630 </tbody></table>
6631 <p>Check out the <a href="#headers"><code>headers</code></a> option to see how to use these parsers in your table (example #1).</p>
6632 Or add a header class name using "sorter-" plus the parser name (example #2 & #3), this includes custom parsers (example #4).
6633 </div>
6634 </td>
6635 <td>
6636 <a href="example-options-headers-digits-strings.html">1</a>
6637 <a href="example-parsers-class-name.html">2</a>
6638 <a href="example-option-built-in-parsers.html">3</a>
6639 <a href="example-parsers.html">4</a>
6640 </td>
6641 </tr>
6642
6643 <tr id="variable-header-indexed">
6644 <td><a href="#" class="permalink">config.$headerIndexed</a></td>
6645 <td>Array</td>
6646 <td>Internally stored Array of headers that represent each column (<span class="version">v2.21.0</span>)
6647 <div class="collapsible">
6648 <br>
6649 The <code>table.config.$headers</code> variable contains ALL header cells, not all of which contain sorting information (data-attributes, class names or sorting information).
6650 <p></p>
6651 This variable targets the <em>last sortable header cell</em> in a particular column; unless an entire column is completely unsortable (checkbox column), then it just picks the last cell in that column.
6652 <p></p>
6653 To make that description less confusing, look at the HTML in the <a href="#variable-headers"><code>config.$headers</code></a> documentation, only the four middle rows (header-index 1-4) will be contained within this variable:
6654 <pre class="prettyprint lang-js">// the resulting config.$headerIndexed for the HTML example in config.$headers will look like this:
6655 console.log( table.config.$headerIndexed );
6656 /* outputs : [
6657 $('&lt;th data-column="0"&gt;header-index 1&lt;/th&gt;'),
6658 $('&lt;th data-column="1"&gt;header-index 2&lt;/th&gt;'),
6659 $('&lt;th data-column="2"&gt;header-index 3&lt;/th&gt;'),
6660 $('&lt;th data-column="3"&gt;header-index 4&lt;/th&gt;')
6661 ] */</pre>
6662 <p></p>
6663 <span class="label label-warning">* NOTE *</span> This variable contains an array of jQuery objects, it is <em>not</em> a collection of jQuery objects, i.e.
6664 <pre class="prettyprint lang-js">var $column = table.config.$headerIndexed[ 0 ]; // jQuery object returned
6665 console.log( $column.hasClass('foo') ); // how to access information
6666
6667 var $headers = $( table.config.$headerIndexed ); // make a collection of jQuery objects
6668 // then use collection manipulation functions
6669 $headers.each(function() {
6670 console.log( $(this).text() );
6671 });</pre></div>
6672 </td>
6673 <td></td>
6674 </tr>
6675
6676 <tr id="variable-headers">
6677 <td><a href="#" class="permalink">config.$headers</a></td>
6678 <td>jQuery Object</td>
6679 <td>Internal list of <strong>all</strong> table header cells (<span class="version">v2.8</span>)
6680 <div class="collapsible">
6681 <p>
6682 <span class="label label-info">*NOTE*</span> The header cells within rows with the <a href="#cssignorerow"><code>cssIgnoreRow</code></a> class (default is <code>&quot;tablesorter-ignoreRow&quot;</code> will not be included in this variable.</p>
6683 <p>Header cells in not-ignored rows are targeted using the jQuery selector from the <a href="#selectorheaders"><code>selectorHeaders</code></a> option</p>
6684 Please note that the headers cells are simply an array of targetted header cells and should not be targeted using a column index. For example, given the following table <code>thead</code> markup, the <code>header-index</code> counts the header <code>th</code> cells and does not actually match the <code>data-column</code> index when extra rows and/or <code>colspan</code> or <code>rowspan</code> are included in any of the header cells:
6685 <pre class="prettyprint lang-html">&lt;thead&gt;
6686 &lt;tr&gt;
6687 &lt;th colspan=&quot;4&quot; data-column=&quot;0&quot; class=&quot;sorter-false&quot;&gt;header-index 0&lt;/th&gt;
6688 &lt;/tr&gt;
6689 &lt;tr&gt;
6690 &lt;th data-column=&quot;0&quot;&gt;header-index 1&lt;/th&gt;
6691 &lt;th data-column=&quot;1&quot;&gt;header-index 2&lt;/th&gt;
6692 &lt;th data-column=&quot;2&quot;&gt;header-index 3&lt;/th&gt;
6693 &lt;th data-column=&quot;3&quot;&gt;header-index 4&lt;/th&gt;
6694 &lt;/tr&gt;
6695 &lt;!-- the next row WILL NOT be included in the config.$headers variable --&gt;
6696 &lt;tr class="tablesorter-ignoreRow"&gt;
6697 &lt;th colspan=&quot;2&quot; data-column=&quot;0&quot;&gt;This cell is not included in the config.$headers&lt;/th&gt;
6698 &lt;th colspan=&quot;2&quot; data-column=&quot;2&quot;&gt;This cell is not included in the config.$headers&lt;/th&gt;
6699 &lt;/tr&gt;
6700 &lt;tr&gt;
6701 &lt;th colspan=&quot;2&quot; data-column=&quot;0&quot; class=&quot;sorter-false&quot;&gt;header-index 5&lt;/th&gt;
6702 &lt;th colspan=&quot;2&quot; data-column=&quot;2&quot; class=&quot;sorter-false&quot;&gt;header-index 6&lt;/th&gt;
6703 &lt;/tr&gt;
6704 &lt;/thead&gt;</pre>
6705 So, in the above example, to target the header cell in the second table column (<code>data-column</code> index of 1), use the following code: <code>table.config.$headers.filter('[data-column=&quot;1&quot;]')</code> or <code>table.config.$headers.eq(2)</code>.<br>
6706 <br>
6707 The <code>table.config.$headers</code> variable is useful within callback functions or when writing widgets that target the table header cells.
6708 </div>
6709 </td>
6710 <td></td>
6711 </tr>
6712
6713 <tr id="variable-table-element">
6714 <td><a href="#" class="permalink">config.table</a></td>
6715 <td>DOM element</td>
6716 <td>Internally stored DOM table element (<span class="version">v2.17.5</span>)
6717 <div class="collapsible">
6718 <br>
6719 The <code>table.config.table</code> variable is useful when certain callback functions only pass the config object; originally you could use <code>config.$table[0]</code>, but this saves that small extra trouble.
6720 </div>
6721 </td>
6722 <td></td>
6723 </tr>
6724
6725 <tr id="variable-table">
6726 <td><a href="#" class="permalink">config.$table</a></td>
6727 <td>jQuery Object</td>
6728 <td>Internally stored jQuery object of the table (<span class="version">v2.7.1</span>)
6729 <div class="collapsible">
6730 <br>
6731 The <code>table.config.$table</code> variable is useful within callback functions or when writing widgets that target the table.
6732 </div>
6733 </td>
6734 <td></td>
6735 </tr>
6736
6737 <tr id="variable-sort-vars">
6738 <td><a href="#" class="permalink">config.sortVars</a></td>
6739 <td>Object</td>
6740 <td>Internally stored object of column specific sort variables (<span class="version">v2.24.0</span>; <span class="version updated">v2.30.7</span>)
6741 <div class="collapsible">
6742 <br>
6743 This object is defined as follows:<br>
6744 <pre class="prettyprint lang-js">// $('table')[0].config.sortVars -> result
6745 [{
6746 // column 0
6747 count: 0, // click count; used as index for order value
6748 order: [ 0, 1, 2 ], // default sort (sortReset: true)
6749 lockedOrder: false, // true if column order is locked (read only)
6750 sortedBy: 'user'
6751 },{
6752 // ...
6753 },{
6754 // column n
6755 count: 0, // click count; used as index for order value
6756 order: [ 0, 1, 2 ], // default sort (sortReset: true)
6757 lockedOrder: false, // true if column order is locked (read only)
6758 sortedBy: 'sorton'
6759 }]</pre>
6760 <ul>
6761 <li><code>count</code>
6762 <ul>
6763 <li>The initial value is <code>-1</code>.</li>
6764 <li>The value is incremented each time the user clicks on a header cell; but it resets to zero once it reaches the end of the order array.</li>
6765 </ul>
6766 </li>
6767 <li><code>order</code>
6768 <ul>
6769 <li>An array that contains the sort sequence for each column.</li>
6770 <li><code>0</code> indicates an ascending sort.</li>
6771 <li><code>1</code> indicates a descending sort.</li>
6772 <li><code>0</code> indicates a reset sort (initial unsorted rows).</li>
6773 <li>Locked sorts will contain either <code>[0, 0]</code> or <code>[1, 1]</code> determined by the lockedOrder setting.</li>
6774 <li>Setting these values to <code>[2, 2]</code> will lock in an unsorted column, but the unsort arrows will still be visible; use a <code>"sorter-false"</code> class instead.</li>
6775 <li>The values of this order can only be modified <em>after</em> tablesorter has initialized.</li>
6776 </ul>
6777 </li>
6778 <li><code>lockedOrder</code>
6779 <ul>
6780 <li>See the <a href="#headers">lockedOrder</a> setting.</li>
6781 <li>It's readonly because it is set during initialization and not used again (future use by a widget?)</li>
6782 </ul>
6783 </li>
6784 <li><code>sortedBy</code>
6785 These values are added to the header cell in a <code>data-sortedBy</code> attribute and may contain:
6786 <ul>
6787 <li><code>'user'</code> (renamed from <code>'mouseup'</code> event) when a column is sorted by a user.</li>
6788 <li><code>'sort'</code> when a column is sorted by triggering a <a href="#sort">sort</a> event on the header.</li>
6789 <li><code>'sorton'</code> when a column is sorted using the <a href="#sorton">sorton</a> method.</li>
6790 <li><code>'sortAppend'</code> when a sorted column is added by the <a href="#sortappend">sortAppend</a> option.</li>
6791 <li><code>'sortForce'</code> when a sorted column is added by the <a href="#sortforce">sortForce</a> option.</li>
6792 </ul>
6793 </li>
6794 </ul>
6795 </div>
6796 </td>
6797 <td></td>
6798 </tr>
6799
6800 <tr id="variable-tbodies">
6801 <td><a href="#" class="permalink">config.$tbodies</a></td>
6802 <td>jQuery Object</td>
6803 <td>Internally stored jQuery object of table non-info block tbodies (<span class="version">v2.7.1</span>)
6804 <div class="collapsible">
6805 <br>
6806 jQuery object of sortable tbodies.<br>
6807 <br>
6808 <span class="label label-warning">Caution!</span> These tbodies are the ones without a class name from the <a href="#cssinfoblock"><code>cssInfoBlock</code></a> option, so the indexing of this jQuery object does not match the actual table tbody indexes.<br>
6809 <br>
6810 The <code>table.config.$tbodies</code> variable is useful within callback functions or when writing widgets that target the table.
6811 </div>
6812 </td>
6813 <td></td>
6814 </tr>
6815
6816 <tr id="variable-hasInitialized">
6817 <td><a href="#" class="permalink">hasInitialized</a></td>
6818 <td>Boolean</td>
6819 <td>Boolean value indicating that tablesorter has been initialized on a table
6820 <div class="collapsible">
6821 <br>
6822 This variable is not stored within the config, as the config would not be defined (an alternative method of determining if tablesorter has been initialized).<br>
6823 <br>
6824 Access it as follows: <code>$('table')[0].hasInitialized</code>. It is <code>true</code> while tablesorter is active on a table, and <code>false</code> if tablesorter was destroyed.
6825 </div>
6826 </td>
6827 <td></td>
6828 </tr>
6829
6830 <tr id="variable-totalrows">
6831 <td><a href="#" class="permalink">config.totalRows</a></td>
6832 <td>Numeric</td>
6833 <td>This variable contains the total number of rows within the table, not including rows within info-only tbodies (<span class="version">v2.17.4</span>; <span class="version updated">v2.17.5</span>)
6834 <div class="collapsible">
6835 <br>
6836 Access this internal value after tablesorter has initialized. It is also included as a variable in the <code>filterEnd</code> event so you can update an external count like this:
6837 <pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd', function(event, data) {
6838 // use data.filteredRows or this.config.filteredRows
6839 $('.filter-rows').html( data.filteredRows );
6840 $('.total-rows').html( data.totalRows );
6841 });</pre><hr>
6842 If using the pager plugin or widget, the value returned from the <code>filterEnd</code> event will not be accurate, so you'll need to bind to the <code>pagerComplete</code> event instead:
6843 <pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd pagerComplete', function(event, data) {
6844 // Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
6845 // both objects contain data.filteredRows & data.totalRows
6846 $('.filter-rows').html( data.filteredRows );
6847 $('.total-rows').html( data.totalRows );
6848 });</pre>
6849 </div>
6850 </td>
6851 <td></td>
6852 </tr>
6853
6854 </tbody>
6855
6856 <!-- non-sorting tbody -->
6857 <tbody id="variables" class="tablesorter-infoOnly">
6858 <tr id="widgetoptions-variables">
6859 <th class="nobold"><a href="#" class="permalink">widgets</a></th>
6860 <th></th>
6861 <th class="nobold">Access the widgetOptions (<code>wo</code>) using any of these methods:
6862 <div class="collapsible">
6863 <br>
6864 <pre class="prettyprint lang-js">// pure js, get the first table (zero index)
6865 var wo = document.getElementsByTagName('table')[0].config.widgetOptions;
6866 // or by table ID
6867 var wo = document.getElementById('mytable').config.widgetOptions;
6868
6869 // using jQuery, get first table (zero index)
6870 var wo = $('table')[0].config.widgetOptions;
6871 // or from the jQuery data
6872 var wo = $('#mytable').data('tablesorter').widgetOptions;
6873 </pre>
6874 </div>
6875 </th>
6876 <th></th>
6877 </tr>
6878 </tbody>
6879
6880 <tbody>
6881 <tr id="variable-any-match">
6882 <td><a href="#" class="permalink">wo.filter_$anyMatch</a></td>
6883 <td>jQuery Object</td>
6884 <td>Only available when the filter widget is active. This variable contains all external search inputs with <code>data-column=&quot;all&quot;</code>, bound using the <a href="#function-bind-search"><code>bindSearch</code></a> function.
6885 <div class="collapsible">
6886 <br>
6887 The <code>table.config.widgetOptions.filter_$anyMatch</code> variable contains one more more search inputs, and is dynamically updated if the <a href="#function-bind-search"><code>bindSearch</code></a> function is called; make sure to set the flag to force a new search so that the values of the altered filters is updated appropriately.
6888 </div>
6889 </td>
6890 <td></td>
6891 </tr>
6892
6893 <tr id="variable-filters">
6894 <td><a href="#" class="permalink">config.$filters</a></td>
6895 <td>jQuery Object</td>
6896 <td>Only available when the filter widget is active. This variable contains all table cells within the filter row.
6897 <div class="collapsible">
6898 <br>
6899 Use the <code>table.config.$filters</code> variable when access to filters is needed. Note! This variable contains the <strong>table cell</strong> and not the actual input because the <a href="#widget-filter-formatter"><code>filter_formatter</code></a> function allows adding other types of value selectors (e.g. jQuery UI slider).
6900 </div>
6901 </td>
6902 <td></td>
6903 </tr>
6904
6905 <tr id="variable-externalfilters">
6906 <td><a href="#" class="permalink">wo.filter_$externalFilters</a></td>
6907 <td>jQuery Object</td>
6908 <td>Only available when the filter widget is active. This variable contains all external search inputs bound using the <a href="#function-bind-search"><code>bindSearch</code></a> function.
6909 <div class="collapsible">
6910 <br>
6911 The <code>table.config.widgetOptions.filter_$externalFilters</code> variable contains an array of jQuery objects pointing to all external inputs, even if the <a href="#function-bind-search"><code>bindSearch</code></a> function is used multiple times.
6912 </div>
6913 </td>
6914 <td></td>
6915 </tr>
6916
6917 <tr id="variable-filter-initialized">
6918 <td><span class="permalink">wo.filter_initialized</span></td>
6919 <td>Boolean</td>
6920 <td>Only available when the filter widget is active. This variable is <code>true</code> once the filter widget has initialized; it is undefined otherwise.</td>
6921 <td></td>
6922 </tr>
6923
6924 <tr id="variable-filteredrows">
6925 <td><a href="#" class="permalink">config.filteredRows</a></td>
6926 <td>Numeric</td>
6927 <td>Only available when the filter widget is active. This variable contains the current number of filtered rows (<span class="version">v2.17.4</span>; <span class="version updated">v2.17.5</span>)
6928 <div class="collapsible">
6929 <br>
6930 This internal value will show an accurate number of filtered rows; which means the count won't include any rows from "information-only" tbodies.<br>
6931 <br>
6932 Access this internal value at any time after the filter widget has initialized, or as a shortcut it is included as a variable in the <code>filterEnd</code> event so you can update an external count like this:
6933 <pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd', function(event, data) {
6934 // use data.filteredRows or this.config.filteredRows
6935 $('.filter-rows').html( data.filteredRows );
6936 $('.total-rows').html( data.totalRows );
6937 });</pre><hr>
6938 If using the pager plugin or widget, the value returned from the <code>filterEnd</code> event will not be accurate, so you'll need to bind to the <code>pagerComplete</code> event instead:
6939 <pre class="prettyprint lang-js">$('table').bind('filterInit filterEnd pagerComplete', function(event, data) {
6940 // Note: data = table.config (filterEnd event); and data = table.config.pager (pagerComplete event)
6941 // both objects contain data.filteredRows & data.totalRows
6942 $('.filter-rows').html( data.filteredRows );
6943 $('.total-rows').html( data.totalRows );
6944 });</pre>
6945 </div>
6946 </td>
6947 <td></td>
6948 </tr>
6949
6950 <tr id="variable-sticky">
6951 <td><a href="#" class="permalink">wo.$sticky</a></td>
6952 <td>jQuery Object</td>
6953 <td>Only available when the stickyHeaders widget (not the css3 version) is active.
6954 <div class="collapsible">
6955 <br>
6956 The <code>table.config.widgetOptions.$sticky</code> variable contains a jQuery object pointing to a cloned table containing the sticky header. The table contained within this variable has a class name of <code>&quot;containsStickyHeaders&quot;</code> versus the original table with a class name of <code>&quot;hasStickyHeaders&quot;</code>.
6957 </div>
6958 </td>
6959 <td></td>
6960 </tr>
6961
6962 </tbody>
6963
6964 <!-- non-sorting tbody -->
6965 <tbody class="tablesorter-infoOnly">
6966 <tr id="pager-variables">
6967 <th class="nobold"><a href="#" class="permalink">pager</a></th>
6968 <th></th>
6969 <th class="nobold">Access the pager options<sup><strong>&dagger;</strong></sup> (<code>p</code>) using any of these methods:
6970 <div class="collapsible">
6971 <br>
6972 <pre class="prettyprint lang-js">// pure js, get the first table (zero index)
6973 var p = document.getElementsByTagName('table')[0].config.pager;
6974 // or by table ID
6975 var p = document.getElementById('mytable').config.pager;
6976
6977 // using jQuery, get first table (zero index)
6978 var p = $('table')[0].config.pager;
6979 // or from the jQuery data
6980 var p = $('#mytable').data('tablesorter').pager;
6981 </pre>
6982 <strong>&dagger;</strong> These methods are the same for both the pager addon and the pager widget.
6983 <p></p>
6984 <span class="label label-info">*NOTE*</span> This pager variable also contains all of the default pager option settings.
6985 <p></p>
6986 <span class="label label-warning">*NOTE*</span> When using the pager widget, changing a value within the <code>widgetOptions</code> for the pager may not update the pager as expected. The pager widget uses most of the values within <code>config.pager</code> instead of the pager <code>widgetOptions</code> after initialization.
6987 </div>
6988 </th>
6989 <th></th>
6990 </tr>
6991 </tbody>
6992
6993 <tbody>
6994
6995 <tr id="variable-pager-container">
6996 <td><a href="#" class="permalink">p.$container</a></td>
6997 <td>jQuery Object</td>
6998 <td>Contains a jQuery object pointing to a pager block(s).
6999 <div class="collapsible">
7000 <br>
7001 The <code>table.config.pager.$container</code> variable is targeted using the pager <a href="#pager-container"><code>container</code></a> option and will have a class name of <code>&quot;tablesorter-pager&quot;</code> applied.<br>
7002 <br>
7003 The container(s) may include the pager navigation arrows, page size selector, page selector and/or output block; the contents are completely customizable and all components are optional.
7004 </div>
7005 </td>
7006 <td></td>
7007 </tr>
7008
7009 <tr id="variable-pager-goto">
7010 <td><a href="#" class="permalink">p.$goto</a></td>
7011 <td>jQuery Object</td>
7012 <td>Contains a jQuery object pointing to an empty select within the pager block(s).
7013 <div class="collapsible">
7014 <br>
7015 The <code>table.config.pager.$goto</code> variable is targeted using the pager <a href="#pager-cssgoto"><code>cssGoto</code></a> option.<br>
7016 <br>
7017 The contents of this select element are dynamically updated if the page size is changed or if the table gets filtered.
7018 </div>
7019 </td>
7020 <td></td>
7021 </tr>
7022
7023 <tr id="variable-pager-size-object">
7024 <td><a href="#" class="permalink">p.$size</a></td>
7025 <td>jQuery Object</td>
7026 <td>Contains a jQuery object pointing to a select with the desired page size settings already in place.
7027 <div class="collapsible">
7028 <br>
7029 The <code>table.config.pager.$size</code> variable is targeted using the pager <a href="#pager-csspagesize"><code>cssPageSize</code></a> option.<br>
7030 <br>
7031 The contents of this select element must be set up with the desired page size settings before initializing tablesorter.<br>
7032 <br>
7033 Also, because Internet Explorer does not appear to get the select value from the option text, please include a value attribute with all options. For example:
7034 <pre class="prettyprint lang-html">&lt;select class=&quot;pagesize&quot;&gt;
7035 &lt;option value=&quot;10&quot;&gt;10&lt;/option&gt;
7036 &lt;option value=&quot;20&quot;&gt;20&lt;/option&gt;
7037 &lt;option value=&quot;30&quot;&gt;30&lt;/option&gt;
7038 &lt;option value=&quot;40&quot;&gt;40&lt;/option&gt;
7039 &lt;/select&gt;</pre>
7040 </div>
7041 </td>
7042 <td></td>
7043 </tr>
7044
7045 <tr id="variable-pager-cache-index">
7046 <td><a href="#" class="permalink">p.cacheIndex</a></td>
7047 <td>Array</td>
7048 <td>Contains an array of zero-based row indexes of rows that currently displayed within the table.
7049 <div class="collapsible">
7050 <br>
7051 For example, if you want to get the parsed values for the rows currently displayed within the pager, use the <code>table.config.pager.cacheIndex</code> variable as follows:
7052 <pre class="prettyprint lang-js">var c = $('table')[0].config,
7053 p = c.pager,
7054 cache = c.cache[0].normalized,
7055 cachedValues = [];
7056 $.each( p.cacheIndex, function(i, v) {
7057 // cache[v] will be an array of parsed values for each cell in selected row
7058 cachedValues.push( cache[v] );
7059 });</pre>
7060 the <code>p.cacheIndex</code> variable get updated whenever the table is sorted, filtered or the pager changes pages or page size.
7061 </div>
7062 </td>
7063 <td></td>
7064 </tr>
7065
7066 <tr id="variable-pager-startrow">
7067 <td><a href="#" class="permalink">p.startRow</a></td>
7068 <td>Numeric</td>
7069 <td>Contains a one-based index of the first row visible in the pager.
7070 <div class="collapsible">
7071 <br>
7072 The <code>{startRow}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value; and it does not correspond to the row index within the cache.
7073 </div>
7074 </td>
7075 <td></td>
7076 </tr>
7077
7078 <tr id="variable-pager-endrow">
7079 <td><a href="#" class="permalink">p.endRow</a></td>
7080 <td>Numeric</td>
7081 <td>Contains a one-based index of the last row visible in the pager.
7082 <div class="collapsible">
7083 <br>
7084 The <code>{endRow}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value; and it does not correspond to the row index within the cache.
7085 </div>
7086 </td>
7087 <td></td>
7088 </tr>
7089
7090 <tr id="variable-pager-filteredpages">
7091 <td><a href="#" class="permalink">p.filteredPages</a></td>
7092 <td>Numeric</td>
7093 <td>Contains the page count, determined by the page size setting, after the table is filtered. It equals the <code>totalPages</code> if no filters are applied.
7094 <div class="collapsible">
7095 <br>
7096 The <code>{filteredPages}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
7097 </div>
7098 </td>
7099 <td></td>
7100 </tr>
7101
7102 <tr id="variable-pager-filteredrows">
7103 <td><a href="#" class="permalink">p.filteredRows</a></td>
7104 <td>Numeric</td>
7105 <td>Contains the number of rows accessible by the pager after the table is filtered. It equals the <code>totalRows</code> if no filters are applied.
7106 <div class="collapsible">
7107 <br>
7108 The <code>{filteredRows}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
7109 </div>
7110 </td>
7111 <td></td>
7112 </tr>
7113
7114 <tr id="variable-pager-page">
7115 <td><a href="#" class="permalink">p.page</a></td>
7116 <td>Numeric</td>
7117 <td>Contains a zero-based index of the current page visible in the pager.
7118 <div class="collapsible">
7119 <br>
7120 The <code>{page}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.<br>
7121 <br>
7122 Initially, this value is set by either the pager <a href="#pager-page"><code>page</code></a> option or from local storage if the <a href="#save-pages"><code>savePages</code></a> option is <code>true</code>. It is then updated by user interaction with the page selector (targeted by the <a href="#pager-cssgoto"><code>cssGoto</code></a> option or programmically by the <a href="#pageset"><code>pageSet</code></a> or <a href="#pageandsize"><code>pageAndSize</code></a> method.
7123 </div>
7124 </td>
7125 <td></td>
7126 </tr>
7127
7128 <tr id="variable-pager-size">
7129 <td><a href="#" class="permalink">p.size</a></td>
7130 <td>Numeric</td>
7131 <td>Contains the currently selected page size.
7132 <div class="collapsible">
7133 <br>
7134 Initially, this value is set by either the pager <a href="#pager-size"><code>size</code></a> option or from local storage if the <a href="#save-pages"><code>savePages</code></a> option is <code>true</code>. It is then updated by user interaction with the size selector (targeted by the <a href="#pager-csspagesize"><code>cssPageSize</code></a> option or programmically by the <a href="#pagesize"><code>pageSize</code></a> or <a href="#pageandsize"><code>pageAndSize</code></a> method.
7135 </div>
7136 </td>
7137 <td></td>
7138 </tr>
7139
7140 <tr id="variable-pager-totalpages">
7141 <td><a href="#" class="permalink">p.totalPages</a></td>
7142 <td>Numeric</td>
7143 <td>Contains the total page count as determined by the page size setting.
7144 <div class="collapsible">
7145 <br>
7146 The <code>{totalPages}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
7147 </div>
7148 </td>
7149 <td></td>
7150 </tr>
7151
7152 <tr id="variable-pager-totalrows">
7153 <td><a href="#" class="permalink">p.totalRows</a></td>
7154 <td>Numeric</td>
7155 <td>Contains the total number of rows within the table
7156 <div class="collapsible">
7157 <br>
7158 The <code>{totalRows}</code> tag in the pager <a href="#pager-output"><code>output</code></a> option is replaced by this value.
7159 </div>
7160 </td>
7161 <td></td>
7162 </tr>
7163
7164 </tbody>
7165
7166 <!-- non-sorting tbody -->
7167 <tbody id="pager-removed-variables" class="tablesorter-infoOnly">
7168 <tr><th colspan="4">Removed Variables</th></tr>
7169 </tbody>
7170
7171 <tbody>
7172
7173 <tr id="variable-extra-headers">
7174 <td><a href="#" class="permalink alert">config.$extraHeaders</a></td>
7175 <td>jQuery Object</td>
7176 <td>Internal list of <strong>all</strong> extra table header cells (<span class="version">v2.16.2</span>; <span class="label label-danger">removed</span> v2.21.3)
7177 <div class="collapsible">
7178 <p>This variable was removed due to it causing memory leak issues. To now find extra headers use <a href="#namespace"><code>config.namespace</code></a> as follows:</p>
7179 <pre class="prettyprint lang-js">$( config.namespace + '_extra_headers' )</pre>
7180 <p>When the <a href="#function-bindevents"><code>bindEvents</code></a> function is used, the extra (external) header cells are added to this variable, and automatically updated with the table headers (<a href="#variable-headers"><code>config.$headers</code></a>).</p>
7181 <p>So, when writing a custom widget that clones the table header, there is no longer a need to update the header class names, it's all done automatically.</p>
7182 </div>
7183 </td>
7184 <td></td>
7185 </tr>
7186
7187 <tr id="variable-extra-tables">
7188 <td><a href="#" class="permalink alert">config.$extraTables</a></td>
7189 <td>jQuery Object</td>
7190 <td>Internal list of <strong>all</strong> extra (cloned) table elements (<span class="version">v2.19.0</span>; <span class="label label-danger">removed</span> v2.21.3)
7191 <div class="collapsible">
7192 <p>This variable was removed due to it causing memory leak issues. To find extra tables use <a href="#namespace"><code>config.namespace</code></a> as follows:</p>
7193 <pre class="prettyprint lang-js">$( config.namespace + '_extra_table' )</pre>
7194 <p>Some widgets need to duplicate parts of the original table to provide functionality (e.g. stickyHeaders, scroller). This saved variable will either not exist or contain a jQuery object pointing to the cloned table elements.</p>
7195 <p>This variable was added for the uitheme widget to allow dynamic updating of themes to the original table as well as all cloned parts.</p>
7196 </div>
7197 </td>
7198 <td></td>
7199 </tr>
7200
7201 </tbody>
7202
7203 </table>
7204
7205 <div class="tip">
7206 <h4>Functions</h4>
7207 <span class="label label-info">TIP!</span> Click on the link in the function 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.
7208 </div>
7209 <table id="functions" class="api tablesorter-blue" data-sortlist="[[0,0]]">
7210 <thead>
7211 <tr>
7212 <th class="setwidth">Function</th>
7213 <th>Description</th>
7214 </tr>
7215 </thead>
7216
7217 <!-- non-sorting tbody -->
7218 <tbody id="functions-core2" class="tablesorter-infoOnly">
7219 <tr><th colspan="2">Core Functions</th></tr>
7220 </tbody>
7221
7222 <tbody>
7223
7224 <tr id="function-fixcolumnwidth">
7225 <td><a href="#" class="permalink">fixColumnWidth</a></td>
7226 <td>This function adds a <code>colgroup</code> element to the table when <a href="#widthfixed"><code>widthFixed</code></a> is <code>true</code>.
7227 <div class="collapsible"><br>
7228 A new <code>colgroup</code> with <code>col</code> elements is only added if:
7229 <ul>
7230 <li><a href="#widthfixed"><code>widthFixed</code></a> is <code>true</code>.</li>
7231 <li>A predefined <code>colgroup</code> element does not already exist in the table *.</li>
7232 </ul>
7233 * <span class="label label-info">Note</span> If a <code>colgroup</code> was added by the plugin, calling this function additional times will refresh the set widths<br>
7234 <br>
7235 Also, the <code>col</code> elements within the <code>colgroup</code> are set with a percentage width to dynamically maintain the fixed column width ratios.<br>
7236 <br>
7237 Use it as follows:
7238 <pre class="prettyprint lang-js">$.tablesorter.fixColumnWidth( table );</pre>
7239 <ul>
7240 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7241 </ul>
7242 </div>
7243 </td>
7244 </tr>
7245
7246 <tr id="function-processtbody">
7247 <td><a href="#" class="permalink">processTbody</a></td>
7248 <td>
7249 This function detaches the targeted tbody from the DOM to allow faster manipulation of the tbody contents (v2.4).
7250 <div class="collapsible">
7251 Use it as follows:
7252 <pre class="prettyprint lang-js">$.tablesorter.processTbody( table, $(tbody), getIt );</pre>
7253 <ul>
7254 <li><code>table</code> - table DOM element (or jQuery object) of table containing the tbody.</li>
7255 <li><code>$(tbody)</code> - tbody jQuery object.</li>
7256 <li><code>getIt</code> - Boolean flag (optional if <code>false</code>).</li>
7257 </ul>
7258 When calling the function, to get a tbody, set the <code>getIt</code> boolean parameter to <code>true</code> and the removed tbody is returned; setting this option to <code>false</code> or optionally not including it will restore the tbody.
7259 <br>
7260 Here is a basic example of how this function is used:
7261 <pre class="prettyprint lang-js">var tbodyIndex, _tbody,
7262 table = $('#my-table')[0],
7263 tbodies = table.tBodies, // use table.config.$tbodies for all tbodies EXcluding information only tbodies
7264 for (tbodyIndex = 0; tbodyIndex &lt; tbodies.length; tbodyIndex++) {
7265 // detach tbody from table
7266 _tbody = $.tablesorter.processTbody( table, tbodies[tbodyIndex], true );
7267 // do something magical to the tbody
7268 _tbody.addClass('unicorn');
7269 // restore tbody
7270 $.tablesorter.processTbody( table, _tbody );
7271 }</pre>
7272 Please note that completely detaching the tbody was found to be a much quicker method of manipulating DOM elements than just hiding the tbody; this is especially true in older browsers.
7273 </div>
7274 </td>
7275 </tr>
7276
7277 <tr id="function-isprocessing">
7278 <td><a href="#" class="permalink">isProcessing</a></td>
7279 <td>This function adds the processing (indeterminant loading icon) to specific or all header cells while processing table elements (v2.4).
7280 <div class="collapsible"><br>
7281 Use it as follows:
7282 <pre class="prettyprint lang-js">$.tablesorter.isProcessing( table, toggle, $ths );</pre>
7283 <ul>
7284 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7285 <li><code>toggle</code> - Boolean flag.</li>
7286 <li><code>$ths</code> - jQuery object of targeted header cells (optional; if excluded all header cells are targeted).</li>
7287 </ul>
7288 When calling the function, set the <code>toggle</code> option to add (<code>true</code>) or remove (<code>false</code>) process indicators. Include any specific header cells within the <code>$ths</code> variable with which to add the process indicator. When <code>$ths</code> is not defined and a sort is applied, the currently sorted header cells will show process indicators.<br>
7289 <br>
7290 All this function does is add or remove a class name of <code>&quot;tablesorter-processing&quot;</code> and the class name contained within the <a href="#cssprocessing"><code>cssProcessing</code> option</a>.<br>
7291 <br>
7292 Here is a basic example of how this function is used:
7293 <pre class="prettyprint lang-js">$('table').bind('sortBegin sortEnd', function(event, table) {
7294 // this is included with the basic functionality of tablesorter
7295 $.tablesorter.isProcessing( this, event === 'sortBegin' );
7296 });</pre>
7297 Please note that currently the processing icons do not animate (see <a href="https://github.com/Mottie/tablesorter/issues/158">issue #158</a>). This is due to javascript being a single-threaded, meaning it only does one task at a time, and maximizing the sorting script. So lots of processing is needed to sort &amp; rebuild the table and thus it has no time for animation. If someone knows of a better solution, please share!
7298 </div>
7299 </td>
7300 </tr>
7301
7302 <tr id="function-cleartablebody">
7303 <td><a href="#" class="permalink">clearTableBody</a></td>
7304 <td>This function empties ALL of the table tbodies (<span class="version updated">v2.17.2</span>).
7305 <div class="collapsible"><br>
7306 Use it as follows:
7307 <pre class="prettyprint lang-js">$.tablesorter.clearTableBody( table );</pre>
7308 <ul>
7309 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7310 </ul>
7311 Please note that this function uses jQuery <code>empty()</code>. All data &amp; event handlers are removed. No where within the tablesorter script or included widgets is this function used, it is left intact for backwards compatibility.
7312 </div>
7313 </td>
7314 </tr>
7315
7316 <tr id="function-bindevents">
7317 <td><a href="#" class="permalink">bindEvents</a></td>
7318 <td>This function adds header event listeners to the targeted cells (v2.8; <span class="version updated">v2.16.2</span>).
7319 <div class="collapsible"><br>
7320 Use it as follows:
7321 <pre class="prettyprint lang-js">$.tablesorter.bindEvents( table, $headers );</pre>
7322 <ul>
7323 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7324 <li><code>$headers</code> - jQuery object of targeted cells.</li>
7325 </ul>
7326 This function allows you to bind the same header event listeners to external headers cells (usually clones of the original table). This includes the triggered <code>sort</code> event, left click (only) to sort, ignoring long clicks (&gt; 250ms), pressing enter to trigger a sort (must have focus and a <code>tabindex</code> attribute) and cancelling selection of text (if the option is set).<br>
7327 <br>
7328 To ensure the columns match the original table, include <code>data-column</code> attributes pointing to the desired column.<br>
7329 <br>
7330 Here is a basic example of how this function is used:
7331 <pre class="prettyprint lang-js">var $table = $('table'),
7332 // make a copy of the table
7333 $clonedTable = $table.clone().addClass('clonedTable').insertAfter($table);
7334 // remove stuff we don't need in the clone
7335 $clonedTable.find('tfoot,tbody').remove();
7336 // bind events to the cloned headers
7337 $.tablesorter.bindEvents( $table, $clonedTable.find('th') );</pre>
7338 In <span class="version">v2.16.2</span>, this function now saves all extra (external) headers to the <a href="#variable-extra-headers"><code>config.$extraHeaders</code></a> variable which allows the plugin to automatically update the sort status.
7339 </div>
7340 </td>
7341 </tr>
7342
7343 <tr id="function-restoreheaders">
7344 <td><a href="#" class="permalink">restoreHeaders</a></td>
7345 <td>This function restores the table headers cells with their original content (v2.8).
7346 <div class="collapsible"><br>
7347 The original header cell content is saved, within the <a href="#variable-headercontent"><code>headerContent</code></a> variable array, before the <a href="#headertemplate"><code>headerTemplate</code></a> is applied and before the <a href="#onrendertemplate"><code>onRenderTemplate</code></a> and <a href="#onrenderheader"><code>onRenderHeader</code></a> callbacks are executed.<br>
7348 <br>
7349 Use it as follows:
7350 <pre class="prettyprint lang-js">$.tablesorter.restoreHeaders( table );</pre>
7351 <ul>
7352 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7353 </ul>
7354 Please note that only header cells that still contain a div with a class name of <code>tablesorter-header-inner</code> will have their contents restored; it assumes that the contents have already been restored.
7355 </div>
7356 </td>
7357 </tr>
7358
7359 <tr id="function-destroy">
7360 <td><a href="#" class="permalink">destroy</a></td>
7361 <td>This function completely removes tablesorter, including all widgets, associated data &amp; event handlers from the table (v2.3.2).
7362 <div class="collapsible"><br>
7363 Use it as follows:
7364 <pre class="prettyprint lang-js">$.tablesorter.destroy( table, removeClasses, callback );</pre>
7365 <ul>
7366 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7367 <li><code>removeClasses</code> - Boolean flag</li>
7368 <li><code>callback</code> - Function executed once tablesorter has been removed.</li>
7369 </ul>
7370 When calling the function, set the <code>removeClasses</code> option to <code>true</code> to include removing of the <code>&quot;tablesorter&quot;</code> class name, tablesorter theme name (e.g. <code>&quot;tablesorter-blue&quot;</code>) and the class name applied by the <a href="#tableclass"><code>tableClass</code> option</a>. The callback function only provides a <code>table</code> (DOM element only) parameter.<br>
7371 <br>
7372 Here is a basic example of how this function is used:
7373 <pre class="prettyprint lang-js">$.tablesorter.destroy( table, true, function(table) {
7374 alert('tablesorter has been removed! No sort for you!');
7375 });</pre>
7376 Please note that only header cells that still contain a div with a class name of <code>tablesorter-header-inner</code> will have their contents restored; it assumes that the contents have already been restored.
7377 </div>
7378 </td>
7379 </tr>
7380
7381 <tr id="function-sortnatural">
7382 <td><a href="#" class="permalink">sortNatural</a></td>
7383 <td>This function sorts the a &amp; b parameter using a natural sort (v2.12; <span class="version updated">v2.28.13</span>).
7384 <div class="collapsible"><br>
7385 Access it as follows:
7386 <pre class="prettyprint lang-js">$.tablesorter.sortNatural(a, b);</pre>
7387 <ul>
7388 <li><code>a</code> - string.</li>
7389 <li><code>b</code> - string to compare.</li>
7390 </ul>
7391 Here is a basic example of how this function is used:
7392 <pre class="prettyprint lang-js">var myArray = [ '1a', '10a', '2a', '2b' ];
7393 // result: ["1a", "2a", "2b", "10a"]
7394 myArray.sort(function(a,b) { return $.tablesorter.sortNatural(a, b); });</pre>
7395 <del>Please note that this natural sort function only accepts strings (added v2.0.6; renamed v2.12)</del>.<br>
7396 As of <span class="version updated">v2.28.13</span>, the natural sort function will convert all values into strings.
7397 </div>
7398 </td>
7399 </tr>
7400
7401 <tr id="function-sorttext">
7402 <td><a href="#" class="permalink">sortText</a></td>
7403 <td>This function sorts the a &amp; b parameter using a basic sort (renamed v2.12).
7404 <div class="collapsible"><br>
7405 Access it as follows:
7406 <pre class="prettyprint lang-js">$.tablesorter.sortText(a, b);</pre>
7407 <ul>
7408 <li><code>a</code> - string.</li>
7409 <li><code>b</code> - string to compare.</li>
7410 </ul>
7411 Here is a basic example of how this function is used:
7412 <pre class="prettyprint lang-js">var myArray = [ '1a', '10a', '2a', '2b' ];
7413 // result: ["10a", "1a", "2a", "2b"]
7414 myArray.sort(function(a,b) { return $.tablesorter.sortText(a, b); });</pre>
7415 </div>
7416 </td>
7417 </tr>
7418
7419 <tr id="function-replaceaccents">
7420 <td><a href="#" class="permalink">replaceAccents</a></td>
7421 <td>This function replaces basic accented characters to better sorting &amp; filtering of table contents (v2.2).
7422 <div class="collapsible"><br>
7423 Use it as follows:
7424 <pre class="prettyprint lang-js">$.tablesorter.replaceAccents(string);</pre>
7425 <ul>
7426 <li><code>string</code> - a string to process &amp; replace accented characters.</li>
7427 </ul>
7428 Here is a basic example of how this function is used:
7429 <pre class="prettyprint lang-js">$.tablesorter.replaceAccents(&quot;&#x00e1;&#x00e0;&#x00e2;&#x00e3;&#x00e4;&quot;); // result: &quot;aaaaa&quot;</pre>
7430 This function is used when the <a href="#sortlocalecompare"><code>sortLocaleCompare</code></a> option is set to <code>true</code>. Please refer to the option and <a href="example-locale-sort.html">the demo</a> for more details on the defaults values and how to add more accented characters.
7431 </div>
7432 </td>
7433 </tr>
7434
7435 <tr id="function-isvalueinarray">
7436 <td><a href="#" class="permalink">isValueInArray</a></td>
7437 <td>This function returns a zero-based index value of the position of the value within the array, otherwise it returns -1 (Modified <span class="version updated">v2.15.6</span>).
7438 <div class="collapsible"><br>
7439 Use it as follows:
7440 <pre class="prettyprint lang-js">$.tablesorter.isValueInArray(value, array);</pre>
7441 <ul>
7442 <li><code>value</code> - value to find within the array.</li>
7443 <li><code>array</code> - array (sortList) to search for the value.</li>
7444 </ul>
7445 Sadly, this function has limited usefulness outside of tablesorter. It is only meant to search a <code>sortList</code> array and determine if a column (value) is already contained within it. Here is a basic example of how this function is used:
7446 <pre class="prettyprint lang-js">var sortList = [ [1,0], [2,0], [0,0] ];
7447 // result: 1
7448 $.tablesorter.isValueInArray(2, sortList);</pre>
7449 After <span class="version">v2.15.6</span>, this function returns a zero-based index of the position of the value within the array parameter, or -1 if the value is not in the array. Previously, this function returned a boolean value of <code>true</code> if the value was contained within the array, or <code>false</code> if not.
7450 </div>
7451 </td>
7452 </tr>
7453
7454 <tr id="function-addparser">
7455 <td><a href="#" class="permalink">addParser</a></td>
7456 <td>This function allows the adding of custom parser scripts to the tablesorter core.
7457 <div class="collapsible"><br>
7458 Access it as follows:
7459 <pre class="prettyprint lang-js">$.tablesorter.addParser(myParser);</pre>
7460 <ul>
7461 <li><code>myParser</code> - object containing parser code.</li>
7462 </ul>
7463 The <code>myParser</code> object must contain a proper template. The template must include an <code>id</code>, <code>is</code>, <code>format</code> and <code>type</code> blocks. Please refer to the <a href="example-parsers.html">writing custom parsers</a> demo page for more details &amp; an example.
7464 </div>
7465 </td>
7466 </tr>
7467
7468 <tr id="function-addInstanceMethods">
7469 <td><a href="#" class="permalink">addInstanceMethods</a></td>
7470 <td>This function allows to add custom methods for config object (<span class="version">v2.21.0</span>).
7471 <div class="collapsible"><br>
7472 Access it as follows:
7473 <pre class="prettyprint lang-js">$.tablesorter.addInstanceMethods(methods);</pre>
7474 <ul>
7475 <li><code>methods</code> - an object containing methods to be added, indexed by method names. These methods can use config object by refering <code>this</code>.</li>
7476 </ul>
7477 Take a look at <a href="#variable-instanceMethods">instanceMethods</a> variable description for more details.
7478 </div>
7479 </td>
7480 </tr>
7481
7482 <tr id="function-getparserbyid">
7483 <td><a href="#" class="permalink">getParserById</a></td>
7484 <td>This function returns the named parser object.
7485 <div class="collapsible"><br>
7486 Access it as follows:
7487 <pre class="prettyprint lang-js">$.tablesorter.getParserById(name);</pre>
7488 <ul>
7489 <li><code>name</code> - the name (or id) of the parser.</li>
7490 </ul>
7491 Use this function as follows:
7492 <pre class="prettyprint lang-js">var parser = $.tablesorter.getParserById(&quot;currency&quot;),
7493 value = parser.format('100%'); // returns 100 (number type, not a string)</pre>
7494 </div>
7495 </td>
7496 </tr>
7497
7498 <tr id="function-haswidget">
7499 <td><a href="#" class="permalink">hasWidget</a></td>
7500 <td>This function allows the checking to see if a widget is installed (<span class="version">v2.17.4</span>).
7501 <div class="collapsible"><br>
7502 Access it as follows:
7503 <pre class="prettyprint lang-js">$.tablesorter.hasWidget( table, 'mywidget');</pre>
7504 <ul>
7505 <li><code>table</code> - table element or jQuery object of the selected table.</li>
7506 <li><code>'mywidget'</code> - ID of the widget to check.</li>
7507 </ul>
7508 This function returns a <code>boolean</code> value, where <code>true</code> means the widget is currently installed and active; and <code>false</code> means the widget is not installed.<br>
7509 <br>
7510 Use this function as follows:
7511 <pre class="prettyprint lang-js">$.tablesorter.hasWidget( $('table'), 'zebra' ); // true</pre>
7512 </div>
7513 </td>
7514 </tr>
7515
7516 <tr id="function-addwidget">
7517 <td><a href="#" class="permalink">addWidget</a></td>
7518 <td>This function allows the adding of custom widget scripts to the tablesorter core (<span class="version updated">v2.19.0</span>).
7519 <div class="collapsible">
7520 <br>
7521 In <span class="version updated">v2.19.0</span>, a <code>&quot;refreshing&quot;</code> parameter was added to the <code>remove</code> widget function to indicate that the widget will be refreshed so it will only be temporarily removed (see <a href="example-widgets.html">this demo</a> for more details).<br>
7522 <br>
7523 Access it as follows:
7524 <pre class="prettyprint lang-js">$.tablesorter.addWidget(myWidget);</pre>
7525 <ul>
7526 <li><code>myWidget</code> - object containing widget code.</li>
7527 </ul>
7528 The <code>myWidget</code> object must contain a proper template. The template must include an <code>id</code> and <code>format</code> blocks. The <code>priority</code>, <code>options</code>, <code>init</code> and <code>remove</code> blocks are optional.<br>
7529 <br>
7530 Please refer to the <a href="example-widgets.html">writing custom widgets</a> demo page for more details &amp; an example.
7531 </div>
7532 </td>
7533 </tr>
7534
7535 <tr id="function-getwidgetbyid">
7536 <td><a href="#" class="permalink">getWidgetById</a></td>
7537 <td>This function returns the named widget object.
7538 <div class="collapsible"><br>
7539 Access it as follows:
7540 <pre class="prettyprint lang-js">$.tablesorter.getWidgetById(name);</pre>
7541 <ul>
7542 <li><code>name</code> - the name (or id) of the widget.</li>
7543 </ul>
7544 Use this function as follows:
7545 <pre class="prettyprint lang-js">var widget = $.tablesorter.getWidgetById(&quot;saveSort&quot;),
7546 table = $('table')[0];
7547 // apply save sort widget to a table; but it will get removed if the refreshWidgets method
7548 // is triggered, unless the table.config.widgets array contains this widget name/id
7549 widget.format( table, table.config, table.config.widgetOptions );</pre>
7550 </div>
7551 </td>
7552 </tr>
7553
7554 <tr id="function-applywidget">
7555 <td><a href="#" class="permalink">applyWidget</a></td>
7556 <td>This function applys (refreshes) all currently selected widgets on a table (<span class="version updated">v2.16.0</span>; <span class="version updated">v2.19.0</span>).
7557 <div class="collapsible"><br>
7558 Use it as follows:
7559 <pre class="prettyprint lang-js">$.tablesorter.applyWidget( table, init, callback );</pre>
7560 <ul>
7561 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7562 <li><code>init</code> - optional, boolean initialization flag.</li>
7563 <li><code>callback</code> - optional, a function executed after all widgets have been applied; the only parameter is <code>table</code> (<span class="version">v2.19.0</span>).</li>
7564 </ul>
7565 The <code>init</code> flag is only set to <code>true</code> to extend the default option values from the widget options block. If the widget(s) have already been applied to the table, just leave this parameter undefined.<br>
7566 <br>
7567 This function is called when the <a href="#applywidgets">applyWidgets</a> method is triggered.
7568 </div>
7569 </td>
7570 </tr>
7571
7572 <tr id="function-refreshwidgets">
7573 <td><a href="#" class="permalink">refreshWidgets</a></td>
7574 <td>This function removes, then reapplies all currently selected widgets on a table (v2.4; <span class="version updated">v2.19.0</span>).
7575 <div class="collapsible">
7576 <br>
7577 In <span class="version updated">v2.19.0</span>, this function was modified to internally use the <a href="#function-removewidget">removeWidget</a> function &amp; a <a href="#refreshcomplete"><code>&quot;refreshComplete&quot;</code></a> event is now triggered upon completion.<br>
7578 <br>
7579 Use it as follows:
7580 <pre class="prettyprint lang-js">$.tablesorter.refreshWidgets( table, doAll, dontapply );</pre>
7581 <ul>
7582 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7583 <li><code>doAll</code> - optional, boolean flag.</li>
7584 <li><code>dontapply</code> - optional, boolean flag.</li>
7585 </ul>
7586 The <code>doAll</code> flag is set to <code>true</code> if all widgets contained with the global <a href="#variable-widgets"><code>$.tablesorter.widgets</code></a> array are to be removed.<br>
7587 When <code>doAll</code> is <code>false</code>, only widgets <em>not contained</em> within the <code>config.widget</code> option are removed; then if the <code>dontapply</code> flag is <code>false</code>, the widgets named in that option are reapplied (without removing them).<br>
7588 <br>
7589 This function is called when the <a href="#refreshwidgets">refreshWidgets</a> method is triggered.
7590 </div>
7591 </td>
7592 </tr>
7593
7594 <tr id="function-removewidget">
7595 <td><a href="#" class="permalink">removeWidget</a></td>
7596 <td>This function removes selected widgets (<span class="version">v2.19.0</span>).
7597 <div class="collapsible"><br>
7598 Use it as follows:
7599 <pre class="prettyprint lang-js">$.tablesorter.removeWidget( table, names, refreshing );</pre>
7600 <ul>
7601 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7602 <li><code>names</code> - string (space or comma separated widget names), an array of widget names, or if <code>true</code> all installed widgets are removed.</li>
7603 <li><code>refreshing</code> - if <code>true</code>, the widget name will not be removed from the <a href="#widgets"><code>widgets</code></a> option; any other setting and the name will be removed.</li>
7604 </ul>
7605 This function is used by the <a href="#function-refreshwidgets">refreshWidgets</a> function (<span class="version">v2.19.0</span>).
7606 </div>
7607 </td>
7608 </tr>
7609
7610 <tr id="function-getcolumndata">
7611 <td><a href="#" class="permalink">getColumnData</a></td>
7612 <td>This function returns the column data from an object based on a column index or classname/id (<span class="version updated">v2.21.1</span>).
7613 <div class="collapsible">
7614 <br>
7615 Use it as follows:
7616 <pre class="prettyprint lang-js">$.tablesorter.getColumnData( table, object, key );</pre>
7617 <ul>
7618 <li><code>table</code> - table DOM element (or jQuery object).</li>
7619 <li><code>object</code> - object containing zero-based column indexes or column class names as a key (e.g. <code>table.config.headers</code> or <code>table.config.widgetOptions.filter_functions</code>; any data found as the value (of the <code>key : value</code> pair) will be returned.</li>
7620 <li><code>key</code> - key to be Object key; this can be a zero-based column index or header class name/id.</li>
7621 </ul>
7622 As a full example, say you have a header cell with a class name of <code>&quot;event&quot;</code>. And you want to use the <code>textExtraction</code> function for that column, then you would use this function as follows:
7623 <pre class="prettyprint lang-js">var table = $('table')[0],
7624 textExtractionFunction = $.tablesorter.getColumnData( table, table.config.textExtraction, &quot;.event&quot; );</pre>
7625 The <code>&quot;.event&quot;</code> key can be replaced with a zero-based column index, if the <code>textExtraction</code> option is set up using indexes.
7626 <p></p>
7627 This function is sometimes used in conjunction with the <code>getData</code> function. This function is called first because the getData function uses the result in the <code>configHeaders</code> parameter - the <code>config.headers</code> option result from this function would be an object and not a function.
7628 </div>
7629 </td>
7630 </tr>
7631
7632 <tr id="function-getcolumntext">
7633 <td><a href="#" class="permalink">getColumnText</a></td>
7634 <td>This utility function returns the entire column text (raw and parsed) as well as other data (<span class="version">v2.21.4</span>; <span class="updated version">v2.24.0</span>).
7635 <div class="collapsible">
7636 <br>
7637 Use it as follows:
7638 <pre class="prettyprint lang-js">$.tablesorter.getColumnText( table, column, callback, rowFilter );</pre>
7639 <ul>
7640 <li><code>table</code> - table DOM element (or jQuery object).</li>
7641 <li><code>column</code> - zero-based column index or <code>'all'</code>.</li>
7642 <li><code>callback</code> - callback function that is called while obtaining data for each cell within the specified column.</li>
7643 <li><code>rowFilter</code> - can be a jQuery selector, function or element to allow targeting specific rows (e.g. <code>&quot;:visible&quot;</code> or <code>&quot;:not(.child-row)&quot;</code>); this parameter is used in a jQuery <code><a class="external" href="http://api.jquery.com/is/">.is()</a></code> function (<span class="version">v2.24.0</span>).</li>
7644 </ul>
7645 When using the callback, there is only one argument (object) passed to this function; it contains the following:
7646 <ul>
7647 <li><code>tbodyIndex</code> - the tbody zero-based index of the current cell.</li>
7648 <li><code>rowIndex</code> - the row zero-based index of the current cell.</li>
7649 <li><code>$row</code> - a jQuery object targeting the current row being processed.</li>
7650 <li><code>$cell</code> - a jQuery object targeting the curretn cell being processed.</li>
7651 <li><code>parsed</code> - parsed text of the current cell.</li>
7652 <li><code>raw</code> - raw (unparsed) text of the current cell.</li>
7653 </ul>
7654 As an example, say you want to make the text of all cells with a value greater than 20 red (assuming the 'red' class name is defined in css). Do it as follows:
7655 <pre class="prettyprint lang-js">var table = $('table')[0];
7656 // targeting the 4th column (zero-based index)
7657 $.tablesorter.getColumnText( table, 3, function( data ) {
7658 if ( data.parsed > 20 ) {
7659 data.$cell.addClass('red');
7660 }
7661 });</pre>
7662 In this example, the goal is to get data from rows visible after filtering. When the callback returns <code>false</code>, that row/cell data will not be included in the resulting data:
7663 <pre class="prettyprint lang-js">var table = $('table')[0],
7664 // getting data from ALL columns, we're just skipping filtered out rows (rows with a "filtered" class)
7665 result = $.tablesorter.getColumnText( table, 'all', function( data ) {
7666 return !data.$row.hasClass('filtered');
7667 });
7668 // let's just assume this example is only showing filter matching rows (rows without a "filtered" class ;)
7669 // result = {
7670 // raw : [ [ 'r1c1', 'r1c2', ..., 'r1cN' ], [ 'r2c1', 'r2c2', ..., 'r2cN' ] ..., [ 'rNc1', 'rNc2', ..., 'rNcN' ] ],
7671 // parsed : [ [ 'r1c1', 'r1c2', ..., 'r1cN' ], [ 'r2c1', 'r2c2', ..., 'r2cN' ] ..., [ 'rNc1', 'rNc2', ..., 'rNcN' ] ],
7672 // $cell : [ [ $r1c1, $r1c2, ..., $r1cN ], [ $r2c1, $r2c2, ..., $r2cN ] ..., [ $rNc1, $rNc2, ..., $rNcN ] ]
7673 // }
7674 </pre>
7675 If the callback isn't used, the function will return the cummulated data for the column (it does not include all of the parameters available within the callback function):
7676 <pre class="prettyprint lang-js">var table = $('table')[0],
7677 // targeting the 4th column (zero-based index)
7678 columnText = $.tablesorter.getColumnText( table, 3 );
7679 // columnText = {
7680 // raw : [ 'cell1', 'cell2', ..., 'celln' ],
7681 // parsed : [ 'cell1', 'cell2', ..., 'celln' ],
7682 // $cell : [ $cell1, $cell2, ..., $celln ]
7683 // }
7684 </pre>
7685 When using the filter widget, you can ignore filtered rows using the following code:
7686 <pre class="prettyprint lang-js">var table = $('table')[0],
7687 // targeting the 4th column (zero-based index); callback function is an empty string & therefore ignored
7688 columnText = $.tablesorter.getColumnText( table, 3, '', ':not(.filtered)' );
7689 // columnText = {
7690 // raw : [ 'cell1', 'cell2', ..., 'celln' ],
7691 // parsed : [ 'cell1', 'cell2', ..., 'celln' ],
7692 // $cell : [ $cell1, $cell2, ..., $celln ]
7693 // }
7694 </pre>
7695 All of these methods of gathering column data might be useful for custom widgets, etc.
7696 <p></p>
7697 <span class="label label-warning">* NOTE *</span> All currently available widgets that gather data from a column will be <em>updated to use this function in v2.22.0</em>.
7698 </div>
7699 </td>
7700 </tr>
7701
7702 <tr id="function-getdata">
7703 <td><a href="#" class="permalink">getData</a></td>
7704 <td>This functions gets the sorter, string, empty, etc options for each column from jQuery data, metadata, header option or header class name ("sorter-false") (v2.1.16).
7705 <div class="collapsible"><br>
7706 priority = jQuery data &gt; meta &gt; headers option &gt; header class name<br>
7707 <br>
7708 Use it as follows:
7709 <pre class="prettyprint lang-js">$.tablesorter.getData(headerCell, configHeaders, key);</pre>
7710 <ul>
7711 <li><code>headerCell</code> - table DOM element (or jQuery object) of targeted header cell.</li>
7712 <li><code>configHeaders</code> - table.config.headers option for the current column.</li>
7713 <li><code>key</code> - get value for this option name, e.g. "sorter".</li>
7714 </ul>
7715 If the value of the "sorter" option is needed for a column, set the <code>key</code> to "sorter" and this function will return the set value, e.g. <code>false</code>, <code>digit</code>, <code>currency</code> etc.<br>
7716 Use this function as follows:
7717 <pre class="prettyprint lang-js">var column = 2,
7718 config = $('table')[0].config,
7719 headerCell = config.$headers.filter('[data-column="' + column + '"]');
7720 // e.g. returns "false" if the header cell has the "sorter-false" class name
7721 $.tablesorter.getData( headerCell, config.headers[column], &quot;sorter&quot; );</pre>
7722 The reason there is a priority is because that is the order in which the values are searched, only the first (higher priority) value is returned.
7723 </div>
7724 </td>
7725 </tr>
7726
7727 <tr id="function-formatfloat">
7728 <td><a href="#" class="permalink">formatFloat</a></td>
7729 <td>This function converts a number string into a number type.
7730 <div class="collapsible"><br>
7731 Use it as follows:
7732 <pre class="prettyprint lang-js">$.tablesorter.formatFloat(string, table);</pre>
7733 <ul>
7734 <li><code>string</code> - a string possibly containing a number.</li>
7735 <li><code>table</code> - table DOM element (or jQuery object) of table (optional; required for non U.S. formatting).</li>
7736 </ul>
7737 If <code>string</code> is empty, not a string type, or not a number (after processing), the string itself is returned.<br>
7738 If <code>table</code> is not provided, the format float function will default to U.S. number formatting. The reason a <code>table</code> parameter is needed is to check the value of the <a href="#usnumberformat"><code>usNumberFormat</code></a> option.<br>
7739 <br>
7740 This function uses the <a href="#usnumberformat"><code>usNumberFormat</code></a> option to determine if either commas or decimals are removed before converting the value within the <code>string</code> parameter into a number type variable. This function does not use the <a href="#function-isdigit"><code>$.tablesorter.isDigit</code></a> function.<br>
7741 <br>
7742 Any numbers wrapped within parentheses are converted into negative numbers; but any other symbols (e.g. currency) are not removed and will cause this function to determine the string as a non-number (e.g. &quot;$1.25&quot; will be returned as a string).<br>
7743 <br>
7744 Use this function as follows:
7745 <pre class="prettyprint lang-js">// result: -2345.67 if usNumberFormat option is true
7746 $.tablesorter.formatFloat( &quot;(2,345.67)&quot;, table );</pre>
7747 </div>
7748 </td>
7749 </tr>
7750
7751 <tr id="function-isdigit">
7752 <td><a href="#" class="permalink">isDigit</a></td>
7753 <td>This function determines if a string contains a number after removing commas, periods, quotes and spaces.
7754 <div class="collapsible"><br>
7755 Use it as follows:
7756 <pre class="prettyprint lang-js">$.tablesorter.isDigit(string);</pre>
7757 <ul>
7758 <li><code>string</code> - a string possibly containing a number.</li>
7759 </ul>
7760 This function will return a boolean value of <code>true</code> if the <code>string</code> parameter contains a number after all commas, decimals, quotes and spaces are removed, and still allow plus or minus signs, or the number wrapped in parenthesis (negative values).<br>
7761 <br>
7762 Use this function as follows:
7763 <pre class="prettyprint lang-js">// boolean value of true returned
7764 $.tablesorter.isDigit( &quot;(2,345.67)&quot; );</pre>
7765 </div>
7766 </td>
7767 </tr>
7768
7769 <tr id="function-computecolumnindex">
7770 <td><a href="#" class="permalink">computeColumnIndex</a></td>
7771 <td>Adds the correct <code>data-column</code> indexing to all rows passed to this function (<span class="version">v2.16</span>; <span class="version updated">v2.25.0</span>).
7772 <div class="collapsible">
7773 <p>In <span class="version">v2.25.0</span>, if a <code>config</code> parameter is included, this function will only add a "data-column" attribute to cells where their internal <code>cellIndex</code> doesn't match its actual column index. This does not apply to internal usage where a "data-column" attribute is set on all header &amp; footer cells.</p>
7774 Use it as follows:
7775 <pre class="prettyprint lang-js">// In v2.25.0, if a config parameter is included "data-columns" are not added
7776 // to cells where their cellIndex and calculated column index match
7777 $.tablesorter.computeColumnIndex($rows, config);</pre>
7778 <ul>
7779 <li><code>$rows</code> - jQuery object of rows in which to add data-column indexes.</li>
7780 <li><code>config</code> - this is the <code>table.config</code> (table configuration variables) object.</li>
7781 </ul>
7782 Example result (without including <code>config</code>):<pre class="prettyprint lang-html">&lt;tr&gt;
7783 &lt;td colspan=&quot;2&quot; data-column=&quot;0&quot;&gt;r0c0&lt;/td&gt;
7784 &lt;td data-column=&quot;2&quot;&gt;r0c2&lt;/td&gt;
7785 &lt;/tr&gt;
7786 &lt;tr&gt;
7787 &lt;td data-column=&quot;0&quot;&gt;r1c0&lt;/td&gt;
7788 &lt;td data-column=&quot;1&quot;&gt;r1c1&lt;/td&gt;
7789 &lt;td data-column=&quot;2&quot;&gt;r1c2&lt;/td&gt;
7790 &lt;/tr&gt;</pre>
7791 Example result (including <code>config</code>):<pre class="prettyprint lang-html">&lt;tr&gt;
7792 &lt;td colspan=&quot;2&quot;&gt;r0c0&lt;/td&gt; &lt;!-- data-column=&quot;0&quot; is not included because it matches the cellIndex property --&gt;
7793 &lt;td data-column=&quot;2&quot;&gt;r0c2&lt;/td&gt;
7794 &lt;/tr&gt;
7795 &lt;tr&gt;
7796 &lt;td&gt;r1c0&lt;/td&gt;
7797 &lt;td&gt;r1c1&lt;/td&gt;
7798 &lt;td&gt;r1c2&lt;/td&gt;
7799 &lt;/tr&gt;</pre>
7800 </div>
7801 </td>
7802 </tr>
7803
7804 <tr id="function-showError">
7805 <td><a href="#" class="permalink">showError</a></td>
7806 <td>This function allows adding/removing a row to the thead, to display any errors (<span class="version">v2.15</span>; <span class="version updated">v2.23.1</span>).
7807 <div class="collapsible">
7808 <p>This function is ONLY included within the <code>widget-pager.js</code> and <code>jquery.tablesorter.pager.js</code> files; in version 3+, I plan to add it as a selectable option in a build.</p>
7809 <p>In <span class="version updated">v2.23.1</span>, a <code>settings</code> parameter was included to make it match the parametered returned by the jQuery <a class="external" href="http://api.jquery.com/ajaxError/"><code>.ajaxError()</code> method</a>.</p>
7810 <p>In <span class="version updated">v2.23.0</span>, this function will accept <code>xhr</code> and <code>exception</code> parameters provided by ajax error messages. To maintain backward compatibility, if <code>xhr</code> is a string, it will be treated as previous <code>message</code> parameter and displayed in the error row without modification.</p>
7811 Use it as follows:
7812 <pre class="prettyprint lang-js">$.tablesorter.showError( table, xhr, settings, exception );</pre>
7813 <ul>
7814 <li><code>table</code> - table DOM element (or jQuery object) of the table.</li>
7815 <li><code>xhr</code> - a plain string, string of an HTML row, or the XMLHttpRequest (XHR) object from ajax error message.</li>
7816 <li><code>settings</code> - a plain object containing the ajax settings, as returned by the ajaxError method.</li>
7817 <li><code>exception</code> - exception string passed from the ajax error message.</li>
7818 </ul>
7819 This function will add a table row to the thead, with a class name from either the pager plugin <code>cssErrorRow</code> option setting, or the pager widget <code>pager_css.errorRow</code> option (the default class name is <code>&quot;tablesorter-errorRow&quot;</code>; and styled within each theme css file).
7820 <p>When passing this function a message string (in the <code>xhr</code> parameter), there are three possibilities:</p>
7821 <ol>
7822 <li>Plain string (with inline HTML is okay) - <code>&quot;&lt;strong&gt;table refuses to cooperate&lt;/strong&gt;&quot;</code></li>
7823 <li>HTML row string - <code>'&lt;tr&gt;&lt;td colspan=&quot;' + table.config.columns + '&quot;&gt;yeah, instead of showing your data... I am taking a nap&lt;/td&gt;&lt;/tr&gt;'</code> (the <a href="#variable-columns"><code>table.config.columns</code> variable</a> contains the number of table columns; use as needed)</li>
7824 <li>undefined - completely leave out a message parameter <code>$.tablesorter.showError( table );</code> to remove all error rows from the table thead.</li>
7825 </ol>
7826 As of <span class="version updated">v2.23.0</span>,
7827 <ul>
7828 <li><span class="label label-warning">*WARNING*</span> the <code>table</code> parameter no longer accepts multiple tables.</li>
7829 <li>If the <code>xhr</code> parameter is not a string, then the pager <a href="#pager-ajaxerror"><code>ajaxError</code></a> callback is called to allow modification of the displayed message.</li>
7830 </ul>
7831 </div>
7832 </td>
7833 </tr>
7834
7835 </tbody>
7836
7837 <!-- non-sorting tbody -->
7838 <tbody id="functions-widget" class="tablesorter-infoOnly">
7839 <tr><th colspan="2">Widget Functions</th></tr>
7840 </tbody>
7841
7842 <!-- widget functions -->
7843 <tbody>
7844
7845 <tr id="function-bindsearch">
7846 <td><a href="#" class="permalink">bindSearch</a></td>
7847 <td>This filter widget function allows binding external search filters to the table (v2.13.3; <span class="version updated">v2.15</span>).
7848 <div class="collapsible"><br>
7849 Access it as follows:
7850 <pre class="prettyprint lang-js">$.tablesorter.filter.bindSearch(table, $els, false);</pre>
7851 <ul>
7852 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7853 <li><code>$els</code> - jQuery object of all input (search) elements to bind.</li>
7854 <li><code>false</code> - boolean flag to force a new search.</li>
7855 </ul>
7856 <p>The <code>table</code> element will only process one table. So if you pass in a jQuery object, only the <em>first table</em> will be bound to the elements (<code>$els</code>).</p>
7857 The external elements (<code>$els</code>) will allow searching the table using "search" and "keyup" events (enter to start &amp; escape to cancel the search), and uses the <a href="#widget-filter-livesearch"><code>filter_liveSearch</code></a> option, or delayed search.<br>
7858 <br>
7859 Include a <code>data-column=&quot;#&quot;</code> attribute (where <code>#</code> is the column number) in the search input, to specify to which column the search should apply ~ see <a href="example-widget-filter-external-inputs.html">this demo</a> for a full example. <span class="label label-warning">Warning!</span>, if no <code>data-column</code> attribute is added to the input, the input will be ignored.<br>
7860 <br>
7861 In <span class="version">v2.15</span>, use a <code>data-column=&quot;all&quot;</code> to bind an external any-match search filter; but note that adding an external any-match filter using this method will not override the filter set by the <a href="#widget-filter-external"><code>filter_external</code></a> option.<br>
7862 <br>
7863 The third function parameter, <code>false</code>, is optional. When set to <code>false</code> it forces the inputs to update their values (same as setting the <code>apply</code> flag when using the <a href="#function-setfilters"><code>setFilters</code></a> function), and reapplies (forces) the current search to be applied again, even if the filter values have not changed; this allows changing the data column attribute dynamically. See the <a href="example-widget-filter-external-inputs.html">filter external inputs demo</a> for an example.<br>
7864 <br>
7865 <span class="label label-warning">Warning!</span> If the third parameter is set to <code>true</code> the saved internal filters (<a href="#variable-filters"><code>config.$filters</code></a>) will be replaced - not recommended!
7866 </div>
7867 </td>
7868 </tr>
7869
7870 <tr id="function-buildselect">
7871 <td><a href="#" class="permalink">buildSelect</a></td>
7872 <td>This filter widget function allows the updating or replacing of filter select options from an external source. (<span class="version">v2.17.5</span>):
7873 <div class="collapsible"><br>
7874 Access it as follows:
7875 <pre class="prettyprint lang-js">$.tablesorter.filter.buildSelect( table, column, options, replace, onlyAvail );</pre>
7876 <ul>
7877 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7878 <li><code>column</code> - zero-based column index.</li>
7879 <li><code>options</code> - array of options, jQuery object of option elements, or HTML string of option elements to apply to the targeted select.</li>
7880 <li><code>replace</code> - a boolean value, which if <code>true</code> all options will be replaced; if <code>false</code> the options will be appended to the current list of options.</li>
7881 <li><code>onlyAvail</code> - an optional boolean flag, which will be ignored if the <code>options</code> parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if <code>true</code>, only the available options will be diplayed.</li>
7882 </ul>
7883 Use this function as follows:<br>
7884 <pre class="prettyprint lang-js">// replace filter select options for the first column with 1,2,3,4
7885 $.tablesorter.filter.buildSelect( $('table'), 0, [ 1, 2, 3, 4 ], true );
7886
7887 // append "Aaron" and "Fred" to the second column's filter select options. These options will remain unsorted.
7888 $.tablesorter.filter.buildSelect( $('table'), 1, $('&lt;option&gt;Aaron&lt;/option&gt;&lt;option&gt;Fred&lt;/option&gt;'), false );</pre>
7889 Please be aware that this function will allow you to modify the select options, but as soon as the user filters any column, all of the select options will refresh and obtain options from the table column, or from the <code>filter_selectSource</code> function.
7890 </div>
7891 </td>
7892 </tr>
7893
7894 <tr id="function-getoptions">
7895 <td><a href="#" class="permalink">getOptions</a></td>
7896 <td>This filter widget function returns all the cached values of the set table column (<span class="version">v2.16.0</span>):
7897 <div class="collapsible"><br>
7898 This function respects the parsed data setting for the column, so it uses the <code>filter_useParsedData</code> option, <code>&quot;filter-parsed&quot;</code> class on the header, or the parser <code>parsed</code> flag settinng (<a href="example-parsers.html">ref</a>).
7899 <p>Use it as follows:</p>
7900 <pre class="prettyprint lang-js">$.tablesorter.filter.getOptions( table, column, onlyAvail );</pre>
7901 <ul>
7902 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7903 <li><code>column</code> - zero-based column index.</li>
7904 <li><code>onlyAvail</code> - an optional boolean flag, which will be ignored if the <code>options</code> parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if <code>true</code>, only the available options will be diplayed.</li>
7905 </ul>
7906 Use this function as follows:<br>
7907 <pre class="prettyprint lang-js">// external filter select
7908 var index, len,
7909 opts = '',
7910 $table = $('table'),
7911 column = 0, // first column
7912 onlyAvail = false, // if true, available rows (visible rows after filtering) are returned
7913 // arry is an array of all text content from a table column; duplicate entries are included!
7914 array = $.tablesorter.filter.getOptions( $table, column, onlyAvail );
7915
7916 // process array; sort & remove duplicates (added v2.23.4)
7917 arry = $.tablesorter.filter.processOptions( $table, column, array );
7918 len = arry.length;
7919
7920 // build options
7921 for ( index = 0; index &lt; len; index++ ) {
7922 opts += '&lt;option value="' + array[ index ] + '"&gt;' + array[ index ] + '&lt;/option&gt;';
7923 }
7924 $('select.external').html( opts );</pre>
7925 <p>Please be aware that this function does not process the array, so the array may contain duplicates and will not be sorted.</p>
7926 The filter <a href="#function-processoptions"><code>processOptions</code></a> function was added in <span class="version">v2.23.4</span> which performs those actions.
7927 </div>
7928 </td>
7929 </tr>
7930
7931 <tr id="function-getoptionsource">
7932 <td><a href="#" class="permalink">getOptionSource</a></td>
7933 <td>This filter widget function returns all the cached values of the set table column (<span class="version">v2.16.0</span>):
7934 <div class="collapsible"><br>
7935 This function returns both the text and the parsed text for a column. So it <strong>ignores</strong> the <code>filter_useParsedData</code> option, <code>&quot;filter-parsed&quot;</code> class on the header, and the parser <code>parsed</code> flag settinng (<a href="example-parsers.html">ref</a>).
7936 <p>Use it as follows:</p>
7937 <pre class="prettyprint lang-js">$.tablesorter.filter.getOptionSource( table, column, onlyAvail );</pre>
7938 <ul>
7939 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7940 <li><code>column</code> - zero-based column index.</li>
7941 <li><code>onlyAvail</code> - an optional boolean flag, which will be ignored if the <code>options</code> parameter is defined or is an empty string; otherwise it is the value passed to the function which finds all table column values; if <code>true</code>, only the available options will be diplayed.</li>
7942 </ul>
7943 Use this function as follows:<br>
7944 <pre class="prettyprint lang-js">// external filter select
7945 var index, len,
7946 opts = '',
7947 $table = $('table'),
7948 column = 0, // first column
7949 onlyAvail = false, // if true, available rows (visible rows after filtering) are returned
7950 // arry is an array of objects [{ text: "Foo", parsed: "foo" }, ...] with duplicates entries removed
7951 arry = $.tablesorter.filter.getOptionSource( $table, column, onlyAvail );
7952
7953 // build options
7954 for ( index = 0; index &lt; len; index++ ) {
7955 opts += '&lt;option value="' + array[ index ].parsed + '"&gt;' + array[ index ].text + '&lt;/option&gt;';
7956 }
7957 $('select.external').html( opts );</pre>
7958 <p>Please be aware that this function is different from the <a href="#function-getoptions"><code>getOptions</code></a> filter function in that an object is returned.</p>
7959 </div>
7960 </td>
7961 </tr>
7962
7963 <tr id="function-processoptions">
7964 <td><a href="#" class="permalink">processOptions</a></td>
7965 <td>This filter widget function returns an array of sorted column data will duplicates removed (<span class="version">v2.23.4</span>).
7966 <div class="collapsible"><br>
7967 Use it as follows:
7968 <pre class="prettyprint lang-js">$.tablesorter.filter.processOptions( table, column, array );</pre>
7969 <ul>
7970 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7971 <li><code>column</code> - zero-based column index (optional).</li>
7972 <li><code>array</code> - An array of items to process.</li>
7973 </ul>
7974 The <code>column</code> parameter is optional, but if included it is used:
7975 <ul>
7976 <li>To check the column header for a <code>filter-select-nosort</code> class name to prevent the sorting of options.</li>
7977 <li>To check the column header for a <code>filter-select-sort-desc</code> class name to preform a descending sort of options.</li>
7978 <li>To check tablesorter's <code>textSorter</code> option in case there are column specific sorting algorhithms set.</li>
7979 </ul>
7980 See the <a href="#function-getoptions"><code>getOptions</code></a> function description or the <a href="#widget-filter-selectsource"><code>filter_selectSource</code></a> option (under "An object containing column keys"; getJSON) for examples which use this function.
7981 </div>
7982 </td>
7983 </tr>
7984
7985 <tr id="function-getfilters">
7986 <td><a href="#" class="permalink">getFilters</a></td>
7987 <td>This filter widget function allows getting an array of the currently applied filters (<span class="version">v2.9</span>; <span class="version updated">v2.15</span>)
7988 <div class="collapsible"><br>
7989 Access it as follows:
7990 <pre class="prettyprint lang-js">$.tablesorter.getFilters(table, flag);</pre>
7991 <ul>
7992 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
7993 <li><code>flag</code> - boolean flag (optional; <code>false</code> by default; filter values obtained from the cache), added <span class="version">v2.15</span>;</li>
7994 </ul>
7995 Use this function as follows:<br>
7996 <pre class="prettyprint lang-js">// use $('table') or $('table.hasFilters') to make sure the table has a filter row
7997 // only required if the stickyHeaders or scroller widget is being used (they duplicate the table)
7998 $.tablesorter.getFilters( $('table') );</pre>
7999 This function returns an array of filter values (e.g. <code>[ '', '', '', '', '', '2?%' ]</code>), or <del><code>false</code></del> an empty array (<span class="version">v2.27.0</span>) if the selected table does not have a filter row or any associated inputs. It will also return an additional parameter if an external input with <code>data-column=&quot;all&quot;</code> containing the value used when matching any table column.<br>
8000 <br>
8001 In <span class="version updated">v2.27.0</span>, this function will always return an array.
8002 <br>
8003 In <span class="version updated">v2.15</span>, this function will also return values from any external filters (set either by the <a href="#filter-external"><code>filter_external</code> option</a> or using the <a href="#function-bindsearch"><code>bindSearch</code> function</a>) - with or without an internal filter row.<br>
8004 <br>
8005 If the second parameter is set to <code>true</code>, it forces the function to get all of the current filter values directly from the inputs. Otherwise, by default, the function returns the last search as found in this stored data <code>$('table').data('lastSearch');</code>.
8006 </div>
8007 </td>
8008 </tr>
8009
8010 <tr id="function-setfilters">
8011 <td><a href="#" class="permalink">setFilters</a></td>
8012 <td>This filter widget function allows setting of the filters; include a <code>true</code> boolean to actually apply the search (<span class="version">v2.9</span>; <span class="version updated">v2.24.3</span>):
8013 <div class="collapsible"><br>
8014 Access it as follows:
8015 <pre class="prettyprint lang-js">$.tablesorter.setFilters(table, filter, apply);</pre>
8016 <ul>
8017 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
8018 <li><code>filter</code> - array of filter values to apply to the table.</li>
8019 <li><code>apply</code> - boolean flag, if <code>false</code> (<del>default setting</del>; default is now <code>true</code> as of v2.24.3), the input values are updated, but the search is not applied to the table.</li>
8020 </ul>
8021 Use this function as follows:<br>
8022 <pre class="prettyprint lang-js">// update filters, but don't apply the search
8023 $.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ], false );
8024
8025 // update filters, AND apply the search (apply is undefined; defaults to true in v2.24.3+)
8026 $.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ] ); // this will now use the search method</pre>
8027 This function returns <code>true</code> if the filters were sucessfully applied, or <code>false</code> if the table does not have a filter row.<br>
8028 <p>In <span class="version updated">v2.24.3</span>, if the <code>apply</code> parameter is left undefined, it will now default to <code>true</code>.</p>
8029 As of <span class="version updated">v2.15</span>, this function will also set values in any external filters (set either by the <a href="#filter-external"><code>filter_external</code> option</a> or using the <a href="#function-bindsearch"><code>bindSearch</code> function</a>). An additional search parameter can be included to match any column, but please include an external input with <code>data-column=&quot;all&quot;</code> using the <code>bindSearch</code> function so your users will know that a search has been applied.<br>
8030 <br>
8031 Also, changed is that when a <code>true</code> value is passed as a third parameter, the search is forced to refresh on the table; otherwise, if the filters set in the search exactly match the previous search, it would be ignored - this was added to prevent numerous ajax calls with exactly the same search or sort parameters (when using the pager).
8032 </div>
8033 </td>
8034 </tr>
8035
8036 <tr id="function-resizablereset">
8037 <td><a href="#" class="permalink">resizableReset</a></td>
8038 <td>This resizable widget function allows resetting column width changes and clearing out the saved set widths (<span class="version">v2.4</span>; <span class="version updated">v2.10.1</span>)
8039 <div class="collapsible"><br>
8040 Use it as follows:
8041 <pre class="prettyprint lang-js">$.tablesorter.resizableReset(table, refreshing);</pre>
8042 <ul>
8043 <li><code>table</code> - table DOM element (or jQuery object) of table(s).</li>
8044 <li><code>refreshing</code> - if this flag is set to <code>true</code>, the stored resize settings will not be cleared; all other settings will clear the storage.</li>
8045 </ul>
8046 This function is used when the user right-clicks on the table header (the <code>refreshing</code> flag is undefined at that time to allow saving the changes).
8047 </div>
8048 </td>
8049 </tr>
8050
8051 <tr id="function-resizeevent">
8052 <td><a href="#" class="permalink">addHeaderResizeEvent</a></td>
8053 <td>Added a <code>resize</code> event to the table headers - used by the stickyHeaders widget, but this is a public function available to any widget (<span class="version">v2.10</span>).
8054 <div class="collapsible"><br>
8055 There is no built-in resize event for non-window elements, so when this function is active it triggers a <code>resize</code> event when the header cell changes size. So, if you are writing your own widget and need a header <code>resize</code> event, just include the <code>jquery.tablesorter.widgets.js</code> file, or just the extract the function from that file.<br>
8056 <br>
8057 Access it as follows:
8058 <pre class="prettyprint lang-js">$.tablesorter.addHeaderResizeEvent(table, disable, { timer : 250 });</pre>
8059 <ul>
8060 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
8061 <li><code>disable</code> - boolean flag, if <code>false</code> events for the targeted table are disabled.</li>
8062 <li><code>timer</code> - currently only the timer option is available for modification.</li>
8063 </ul>
8064 Enable these triggered events as follows:
8065 <pre class="prettyprint lang-js">var table = $('table')[0],
8066 disable = false,
8067 options = {
8068 timer : 250 // header cell size is checked every 250 milliseconds (1/4 of a second)
8069 };
8070 $.tablesorter.addHeaderResizeEvent( table, disable, options );</pre>Then use it in your custom widget as follows:
8071 <pre class="prettyprint lang-js">$(table).on('resize', function(event, columns) {
8072 // columns contains an array of header cells that were resized
8073 // this seemed like a better idea than firing off a resize event for every
8074 // column when the table adjusts itself to fit within its container
8075 event.stopPropagation(); // optional
8076 // do something
8077 console.log( columns );
8078 });</pre>To disable these resize events, use this code:<pre class="prettyprint lang-js">// Disable resize event triggering:
8079 var table = $('table')[0];
8080 $.tablesorter.addHeaderResizeEvent( table, true );</pre>
8081 </div>
8082 </td>
8083 </tr>
8084
8085 <tr id="function-storage">
8086 <td><a href="#" class="permalink">storage</a></td>
8087 <td>This function allows saving specific table data (especially widgets) to local storage (cookie fallback for no browser support) (v2.1)
8088 <div class="collapsible"><br>
8089 Access it as follows:
8090 <pre class="prettyprint lang-js">$.tablesorter.storage(table, key, value, options);</pre>
8091 <ul>
8092 <li><code>table</code> - table DOM element (or jQuery object) of table.</li>
8093 <li><code>key</code> - name of the variable to save</li>
8094 <li><code>value</code> - value of the variable that is saved (for saving only); set as <code>undefined</code> if wanting to get a value with options.</li>
8095 <li><code>options</code> - storage options; see below</li>
8096 </ul>
8097 This function attempts to give every table a unique identifier using both the page url and table id (or index on the page if no id exists), by default. Here is a usage example and a look at what is stored within the local storage:
8098 <pre class="prettyprint lang-js">$.tablesorter.storage( $('#tablesorter-demo')[0], 'test', '123');
8099 // stored under the "test" value as {"/tablesorter/docs/":{"tablesorter-demo":"123"}}
8100
8101 </pre>
8102 The saved table url & id can be overridden by setting table data attributes <code>data-table-page</code> (url) and <code>data-table-group</code> (id), as in this sample markup:
8103 <pre class="prettyprint lang-html">&lt;table class=&quot;tablesorter&quot; data-table-page=&quot;mydomain&quot; data-table-group=&quot;financial&quot;&gt;...&lt;/table&gt;)</pre>
8104 To change the default data attributes, use the <code>options</code> to modify them as follows:<pre class="prettyprint lang-js">$.tablesorter.storage( table, key, value, {
8105 // table id/group id
8106 id: 'group1',
8107 // this group option sets name of the table attribute with the ID;
8108 // but the value within this data attribute is overridden by the above id option
8109 group: 'data-table-group',
8110
8111 // table pages
8112 url: 'page1',
8113 // this page option sets name of the table attribute with the page/url;
8114 // but the value within the data attribute is overridden by the above url option
8115 page: 'data-table-page',
8116
8117 // Option added v2.28.8; use the first letter of (l)ocal, (s)ession or (c)ookie
8118 // to set the desired storage type. Any setting of this option will override
8119 // any setting in the `useSessionStorage` option.
8120 storageType: 'l', // local
8121
8122 // DEPRECATED in v2.28.8; use the `storageType` option.
8123 // Option added v2.21.3; if `true` the storage function will use sessionStorage
8124 // if not defined, the `config.widgetOptions.storage_useSessionStorage` setting is checked
8125 // if no settings are found, it will default to `false`, and use localStorage
8126 // useSessionStorage: false
8127
8128 });</pre>
8129 The priority of table ID settings is as follows:
8130 <ol>
8131 <li><code>options.id</code> setting</li>
8132 <li>Table data attribute (<code>&quot;data-table-group&quot;</code> by default) value</li>
8133 <li><a href="#widget-storage-table-id"><code>widgetOptions.storage_tableId</code></a> option</li>
8134 <li>Table id attribute</li>
8135 <li>Index of the table (compared to other tables with a "tablesorter" class name) on the page</li>
8136 </ol>
8137 The priority of table url (group) settings is as follows:
8138 <ol>
8139 <li><code>options.url</code> setting</li>
8140 <li>Table data attribute (<code>&quot;data-table-page&quot;</code> by default) value</li>
8141 <li><a href="#widget-storage-fixed-url"><code>widgetOptions.storage_fixedUrl</code></a> option value</li>
8142 <li><a href="#fixedurl" class="alert" title="deprecated"><code>config.fixedUrl</code></a> option value</li>
8143 <li><code>window.location.pathname</code></li>
8144 </ol>
8145 <br>
8146 The <a href="#widget-storage-fixed-url"><code>storage_fixedUrl</code></a> widget option allows you to override the current page url (it doesn't need to be a url, just some constant value) and save data for multiple tables across a domain. The value from this option has a lower priority than the <code>options</code> id or group settings (see priority list above).<br>
8147 <br>
8148 When using the storage utility to <em>get</em> a value <em>and</em> use custom table options, set the <code>value</code> parameter as <code>undefined</code>.<br>
8149 <br>
8150 Lastly, this storage utility function needs the <code>parseJSON</code> function available in jQuery v1.4.1+.
8151 </div>
8152 </td>
8153 </tr>
8154
8155 </tbody>
8156 </table>
8157
8158 <a id="Download"></a>
8159 <h1>Download</h1>
8160
8161 <strong>File Downloads</strong>
8162 <ul>
8163 <li>
8164 Get all files (plugin, documentation, add-ons, themes):
8165 <a class="btn btn-primary" href="https://github.com/Mottie/tablesorter/archive/master.zip">zip</a>
8166 or
8167 <a class="btn btn-primary" href="https://github.com/Mottie/tablesorter/archive/master.tar.gz">tar.gz</a>
8168 </li>
8169 <li>Download a <a href="https://github.com/Mottie/tablesorter/releases">previous release</a>.</li>
8170 <li>Install with <a class="external" href="http://bower.io/">bower</a>: <code>bower install jquery.tablesorter</code></li>
8171 <li>Install with <a class="external" href="http://nodejs.org/">node.js</a>: <code>npm install tablesorter</code></li>
8172 <li>Use CDN: <a class="external" href="https://cdnjs.com/libraries/jquery.tablesorter">jquery.tablesorter</a></li>
8173 </ul>
8174
8175 <strong id="Download-Required">Required:</strong>
8176 <ul>
8177 <li><a class="external" href="http://jquery.com/download/">jQuery</a> (1.2.6 or higher; some widgets, demos & <a class="external" href="http://api.jquery.com/data/#data-html5">HTML5 data-attributes</a> need jQuery 1.4.3+)</li>
8178 <li><a href="../dist/js/jquery.tablesorter.min.js">jquery.tablesorter.min.js</a> (minified for production - please put the file on your server)</li>
8179 </ul>
8180
8181 <strong id="Download-Addons">Optional / Add-Ons:</strong>
8182 <ul>
8183 <li><a class="external" href="https://github.com/jquery-orphans/jquery-metadata">jQuery Metadata 2.1</a> (required for setting <a href="#metadata">inline options</a>)</li>
8184 <li><a href="../js/jquery.tablesorter.js">jquery.tablesorter.js</a></li>
8185 <li><a href="../addons/pager/jquery.tablesorter.pager.js">jquery.tablesorter.pager.js</a> (<a href="example-pager.html">demo</a>)</li>
8186 <li><a href="../js/jquery.tablesorter.widgets.js">jquery.tablesorter.widgets.js</a> (includes the jQuery UI theme, columns styling, resizable columns, filter, sticky header and save sort widgets).</li>
8187 </ul>
8188
8189 <strong id="Download-Themes">Themes:</strong>
8190 <p>Theme zip files have been removed. There are now numerous themes available which <a href="themes.html">can be seen here</a>.</p>
8191
8192 <a id="Compatibility"></a>
8193 <h1>Browser Compatibility</h1>
8194
8195 <p>tablesorter has been tested successfully in the following browsers with Javascript enabled:</p>
8196 <ul>
8197 <li>Firefox 2+</li>
8198 <li>Internet Explorer 6+</li>
8199 <li>Safari 2+</li>
8200 <li>Opera 9+</li>
8201 <li>Konqueror</li>
8202 </ul>
8203
8204 <p><a class="external" href="http://jquery.com/browser-support/">jQuery Browser Compatibility</a></p>
8205
8206 <a id="Support"></a>
8207 <h1>Support</h1>
8208
8209 <p>First, please review the <a class="external" href="https://github.com/Mottie/tablesorter/wiki/FAQ">FAQ</a> page to see if it will help you resolve the problem.</p>
8210
8211 <p>If you are having a problem with the plugin or you want to submit a feature request, please <a class="external" href="https://github.com/Mottie/tablesorter/issues">submit an issue</a>.</p>
8212
8213 <p>Support is also available from <a class="external" href="http://stackoverflow.com/questions/tagged/tablesorter">stackoverflow</a>.</p>
8214
8215 <p>If you would like to contribute, <a class="external" href="https://github.com/Mottie/tablesorter">fork a copy on github</a>.</p>
8216
8217 <p>Some basic <a href="../test.html">unit testing</a> has been added (v2.6). If you would like to add more or report a problem, please use the appropriate link above.</p>
8218
8219 <p>For questions about jQuery, try <a class="external" href="http://irc.jquery.org/">irc</a>, <a class="external" href="http://stackoverflow.com/tags/jquery/info">stackoverflow</a>, or the <a class="external" href="http://forum.jquery.com/">jQuery forums</a>.</p>
8220
8221 <a id="Credits"></a>
8222 <h1>Credits</h1>
8223 <p>Written by Christian Bach.</p>
8224 <p>
8225 Documentation written by <a class="external" href="http://www.ghidinelli.com">Brian Ghidinelli</a>,
8226 based on <a class="external" href="http://malsup.com/jquery/">Mike Alsup's</a> great documention.
8227 </p>
8228 <p>
8229 Additional &amp; Missing documentation, alphanumeric sort, numerous widgets, unit testing and other changes added by <a class="external" href="https://github.com/Mottie/tablesorter">Mottie</a>.
8230 </p>
8231 <p>
8232 Thanks to all that have contributed code, comments, feedback and everything else. A special thanks goes out to:
8233 </p>
8234 <ul>
8235 <li><a href="https://github.com/thezoggy">thezoggy</a></li>
8236 <li><a href="https://github.com/TheSin-">TheSin-</a></li>
8237 <li><a href="https://github.com/NickCraver">NickCraver</a></li>
8238 <li><a href="https://github.com/themilkman">themilkman</a> (maintains <a href="https://github.com/themilkman/jquery-tablesorter-rails">jquery-tablesorter-rails</a>)</li>
8239 <li><a href="https://github.com/VorontsovIE">VorontsovIE</a></li>
8240 <li>and <a href="https://github.com/Mottie/tablesorter/graphs/contributors">all the contributors</a>!</li>
8241 </ul>
8242 <p></p>
8243 <a class="external" href="http://ejohn.org">John Resig</a> for the fantastic <a class="external" href="http://jquery.com">jQuery</a>
8244 </div>
8245
8246 <!-- jQuery -->
8247 <script src="js/jquery-latest.min.js"></script>
8248 <script async src="js/jquery-migrate-3.1.0.min.js"></script>
8249 <script async src="js/jquery-ui.min.js"></script>
8250 <script async src="js/prettify.js"></script>
8251 <script async src="js/docs.js"></script>
8252 <script async src="js/search.js"></script>
8253 <!--[if lte IE 8]>
8254 <script src="js/search-ie.js"></script>
8255 <![endif]-->
8256
8257 <!-- Tablesorter: required -->
8258 <script src="../js/jquery.tablesorter.combined.js"></script>
8259 <script async>
8260 $.extend( $.tablesorter.defaults, {
8261 theme: 'blue',
8262 widthFixed: true
8263 });
8264 $('#tablesorter-demo').tablesorter({widgets:['zebra']});
8265 setTimeout(function(){
8266 $('.compatibility').tablesorter();
8267 $('table.options, table.api').tablesorter({widgets:['stickyHeaders']});
8268 }, 1000);
8269 </script>
8270
8271 </body>
8272 </html>