<iframeclass="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>
<iframeclass="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>
<li>Multi-tbody sorting - see the <ahref="#options">options</a> table below</li>
<li>Parsers for sorting text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats), time. <ahref="example-parsers.html">Add your own easily</a></li>
<spanclass="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!
<spanclass="label label-info">NOTE!</span> tablesorter will auto-detect most data types including numbers, dates, ip-addresses for more information see <ahref="#Examples">Examples</a>.
<li>Sort direction (using <ahref="#sortinitialorder"><code>sortInitialOrder</code></a> option [<ahref="example-option-sort-order.html">demo</a>], or <ahref="example-options-headers-order.html">other methods</a>).</li>
<li><ahref="example-options-headers.html">Disable sort for a column</a> (<spanclass="version updated">v2.18.1</span>).</li>
<li><ahref="example-widget-column-selector.html">Disable sort for an entire row</a> (<ahref="#cssignorerow"><code>cssIgnoreRow</code></a> class; v2.18.4).</li>
<li><ahref="example-option-sort-force.html">Force a default sorting order</a> (<ahref="#sortforce"><code>sortForce</code></a>).</li>
<li><ahref="example-option-sort-append.html">Append a sort to the selected sorting order</a> (<ahref="#sortappend"><code>sortAppend</code></a>; <spanclass="version updated">v2.24.0</span>).</li>
<li><ahref="example-trigger-sort.html">Sort table using a link outside the table</a> (external link; <spanclass="updated version">v2.17.0</span>).</li>
<li><ahref="example-child-rows.html">Attach child rows (rows that sort with their parent row)</a> (<spanclass="updated version">v2.15.12</span>).</li>
<li><ahref="example-colspan.html">Sort & filter with colspans</a> (<ahref="#duplicatecolspan"><code>duplicateSpan</code></a>; <spanclass="version">v2.25.0</span>).</li>
<li>The <ahref="example-option-theme-bootstrap-v4.html">Bootstrap v4.x</a> theme (<spanclass="version">v2.28.4</span>) does not require the uitheme widget!</li>
<li><ahref="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> (<ahref="#stringto"><code>stringTo</code></a>; v2.0.10).</li>
<li><ahref="example-empty-table.html">Initializing tablesorter on a empty table</a>.</li>
<li><ahref="example-ajax.html">Appending table data with ajax</a> (<ahref="#update"><code>update</code></a>).</li>
<li><ahref="example-add-rows.html">Adding a table row</a> (<ahref="#addrows"><code>addRows</code></a>; v2.0.16).</li>
<li><ahref="example-update-all.html">Update an entire table column (<code>thead</code> and <code>tbody</code>)</a> (<ahref="#updateall"><code>updateAll</code></a>; <spanclass="version">v2.8</span>).</li>
<li><ahref="example-update-cell.html">Update the table after cell content has changed</a> (<ahref="#updatecell"><code>updateCell</code></a>).</li>
<li><ahref="example-pager.html">Pager plugin</a> - examples of how to add and remove rows.</li>
<li><ahref="example-option-render-header.html">Modifying the Header during rendering</a> (<ahref="#onrenderheader"><code>onRenderHeader</code></a>).</li>
<li><ahref="example-option-render-template.html">Modifying the Header using a template</a> (<ahref="#headertemplate"><code>headerTemplate</code></a>; v2.7).</li>
<li>*Note* you can use class names (version 2.0.11+, <ahref="example-parsers-class-name.html">demo</a>), or jQuery data (version 2.3+, <ahref="example-parsers-jquery-data.html">demo</a>) instead of meta data.</li>
<li><ahref="example-meta-sort-list.html">Set a initial sorting order using metadata</a>.</li>
<li><ahref="example-meta-headers.html">Disable header using metadata</a>.</li>
<li><ahref="example-meta-parsers.html">Setting column parser using metadata</a>.</li>
<spanclass="xsmall"><spanclass="results">†</span> these widgets are included in the <code>jquery.tablesorter.widgets.js</code> file (except for extra filter formatter functions).</span>
<li><ahref="example-widget-filter-custom-search2.html">custom search type (example #2: date range)</a> (<spanclass="version">v2.19.1</span>; <spanclass="version updated">v2.24.6</span>).</li>
<li><ahref="example-parsers-dates.html">Date parsers</a> (<spanclass="version">v2.8</span>; <spanclass="version updated">v2.28.11</span>; includes weekday, month, two-digit year &<aclass="external"href="https://sugarjs.com/docs/#/DateParsing">sugar.js</a> date parsers; a <aclass="external"href="http://www.datejs.com/">datejs</a> parser is also available).</li>
<li><ahref="example-parsers-date-range.html">Date range parsers</a> (<spanclass="version">v2.21.0</span>; <spanclass="version updated">v2.25.0</span>); if filters, include the <ahref="example-widget-filter-custom-search2.html">insideRange</a> filter search type.</li>
<li><ahref="example-parsers-ignore-articles.html">Ignore leading articles parser</a> (Ignore "A", "An" and "The" in titles) (<spanclass="version">v2.8</span>).</li>
<li><ahref="example-parsers-globalize.html">jQuery Globalize</a> (number & date parsers; <spanclass="version">v2.22.0</span>; <spanclass="version updated">v2.25.0</span>).</li>
<li><ahref="example-parsers-ip-address.html">Network (IPv4, IPv6 and MAC address parser</a> (<spanclass="version">v2.12</span>; <spanclass="version updated">v2.22.0</span>; <spanclass="label warning">NOTE</span> "ipAddress" parser moved to this file in v2.18.0).</li>
<li><spanclass="label label-info">Alpha</span><ahref="../beta-testing/example-widget-column-reorder.html">Column reorder widget</a> - not working 100% with sticky headers.</li>
<li><spanclass="label label-info">Alpha</span> Column reorder using the <aclass="external"href="http://stackoverflow.com/a/27770224/145346">dragtable widget</a> (non-mod version).</li>
<spanclass="label label-info">TIP!</span> Click on the link in the property column to reveal full details (or <ahref="#"class="toggleAll">toggle</a>|<ahref="#"class="showAll">show</a>|<ahref="#"class="hideAll">hide</a> all) or double click to update the browser location.
<td>Any <code>colspan</code> cells in the tbody may have its content duplicated in the cache for each spanned column (<spanclass="version">v2.25.0</span>; <spanclass="version updated">v2.25.8</span>).
<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 & filter columns because a cell spanning all columns will only work with one parser.</p>
<p>In <spanclass="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 <ahref="http://jsfiddle.net/Mottie/aoLgu7f9/18/">demo</a> for an example).</p>
<preclass="prettyprint lang-js">// this row: <tr><td colspan="3">foo</td><td>bar</td></tr> results in this row cache:
<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>
<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>
Changed to empty string (<code>""</code>) in v2.11, as the <code>"tablesorter-headerAsc"</code> class will always be added to a header cell with an ascending sort; this option now contains any additional class names to add.
Default changed v2.5 to <code>"tablesorter-headerAsc"</code>. Default changed v2.1.7 to <code>"tablesorter-headerSortUp"</code>. Original default: <code>"headerSortUp"</code></div>
<td>Add this css class to a child row that should always be attached to its parent. Click on the "cssChildRow" link to toggle the view on the attached child row. Previous default was <code>"expand-child"</code> (Modified v2.4).</td>
Changed to empty string in v2.11, as the <code>"tablesorter-headerDesc"</code> class will always be added to a header cell with a descending sort; this option now contains any additional class names to add.
Default changed v2.5 to <code>"tablesorter-headerDesc"</code>. Default changed v2.1.7 to <code>"tablesorter-headerSortDown"</code>. Original default: <code>"headerSortDown"</code></div>
Changed to empty string in v2.11, as the <code>"tablesorter-header"</code> class will always be added to the table headers; this option now contains any additional class names to add.
Changed to empty string in v2.11, as the <code>"tablesorter-headerRow"</code> class will always be added to a table header row; this option now contains any additional class names to add.<br>
<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>
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 <ahref="#headertemplate"><code>headerTemplate</code></a> option includes the icon tag (<code>{icon}</code>).<br>
<br>
In v2.4, an <code><i></code> element, with this class name, is automatically appended to the header cells. To prevent the plugin from adding an <code><i></code> element to the headers, set the <code>cssIcon</code> option to an empty string.<br>
<td>The CSS style added to the header cell icon when the column has an ascending sort (<spanclass="version">v2.18.3</span>).
<divclass="collapsible"><br>
This class is only applied when the <ahref="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <ahref="#cssicon"><code>cssIcon</code></a> option.
<td>The CSS style used to style the header cell icon when the column has a descending sort (<spanclass="version">v2.18.3</span>)
<divclass="collapsible"><br>
This class is only applied when the <ahref="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <ahref="#cssicon"><code>cssIcon</code></a> option.
<td>The CSS style used to style the header cell icon when the column does not have a sort applied (<spanclass="version">v2.18.3</span>)
<divclass="collapsible"><br>
This class is only applied when the <ahref="#headertemplate"><code>headerTemplate</code></a> option includes a <code>{icon}</code> tag or an HTML element with the class name from the <ahref="#cssicon"><code>cssIcon</code></a> option.
<td>Additional CSS class applied to style the header when no sort is applied (<spanclass="version">v2.15</span>).
<divclass="collapsible"><br>
A <code>"tablesorter-headerUnSorted"</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.
Changed to empty string in v2.11, as the <code>"tablesorter-processing"</code> class will always be added to a table cells during processing; this option now contains any additional class names to add.<br>
<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 <ahref="#showprocessing"><code>showProcessing</code></a> option to <code>false</code>.</p>
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.
<spanclass="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.
<td>Class name added to element inside header. Clicking on that element, or any elements within it won't cause a sort. (<spanclass="version">v2.20.0</span>).</td>
Header rows with this class name will not be added into the <ahref="#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>
In previous versions, this option was set as "us", "uk" or "dd/mm/yy". This option was modified to better fit needed date formats. It will only work with four digit years!<br>
The sorter should be set to "shortDate" and the date format can be set in the "dateFormat" option or set for a specific columns within the "headers" option.
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.
<li><code>emptyMax</code> - sort empty table cells as having a value greater than the <em>max</em> (more positive) value (<spanclass="version">v2.16.2</span>).</li>
<li><code>emptyMin</code> - sort empty table cells as having a value greater than the <em>min</em> (more negative) value (<spanclass="version">v2.16.2</span>).</li>
For example, to disable sorting on the first two columns of a table: <code>headers: { 0: { sorter: false}, 1: {sorter: false} }</code>.<br>
<br>
The plugin attempts to detect the type of data that is contained in a column, but if it can't figure it out then it defaults to alphanumeric. You can easily override this by setting the header argument (or column parser).
See the full list of <ahref="#parsers">default parsers</a> here or <ahref="example-parsers.html">write your own</a>.
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:
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>
<br>
In <spanclass="version updated">v2.17.0</span>, you can reference the column(s) using a class name, id or column index.
<spanclass="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>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.
<td>This is a template string which allows adding additional content to the header while it is being built (v2.7; <spanclass="version updated">v2.17.8</span>).
In <spanclass="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>
<code>{content}</code> will be replaced by the current header HTML content.<br>
<code>{icon}</code> will be replaced by <code><i class="tablesorter-icon"></i></code>, but only if a class name is defined in the <code>cssIcon</code> option.<br>
After the template string is built, the <code>onRenderTemplate</code> function is called to allow further manipulation. Please read more about this <ahref="#onrendertemplate"><code>onRenderTemplate</code> function</a> and/or check out the example (link to the right).
});</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>
<td>Apply widgets after table initializes (v2.3.5).
<divclass="collapsible">
When true, all widgets set by the <code>widgets</code> option will apply after tablesorter has initialized, this is the normal behavior.<br>
<br>
If false, the each widget set by the <code>widgets</code> option will be initialized, meaning the "init" function is run, but the format function will not be run. This is useful when running the pager plugin after the table is set up. The pager plugin will initialize, then apply all set widgets.<br>
<br>
Why you ask? Well, lets say you have a table with 1000 rows that will have the pager plugin applied to it. Before this option, the table would finish its setup, all widgets would be applied to the 1000 rows, pager plugin initializes and reapplies the widgets on the say 20 rows showing; making the widget application to 100 rows unnecessary and a waste of time. So, when this option is false, widgets will only be applied to the table after the pager is set up.
<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 (<spanclass="version">v2.18.0</span>)
<divclass="collapsible">
<br>
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>
<br>
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>
<br>
The template string *must* contain the <code>{name}</code> tag.
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 (<spanclass="version updated">v2.18.0</span>).
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 (<aclass="external"href="http://www.pengoworks.com/workshop/jquery/tablesorter/tablesorter.htm">source</a>).<br>
<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>
<li><code>config</code> - The current <code>table.config</code>.</li>
<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 (<spanclass="version">v2.18.0</span>).</li>
<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>
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).
The <code>onRenderTemplate</code> function receives a column index and template string parameters. The template string, from the <ahref="#headertemplate"><code>headerTemplate</code> option</a>, will already have the <code>{icon}</code> and <code>{content}</code> tags replaced; it's just a string of formatted HTML. When done manipulating this string, return it. Here is an example:
});</pre>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>
From the example function above, you'll end up with something similar to this HTML (only the thead is shown)<preclass="prettyprint lang-html"><thead>
<br>Added <code>></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.
<td>This CSS class name can be applied to all rows that are to be removed prior to triggering a table update. (v2.1).
<divclass="collapsible">
<br>
It was necessary to add this option because some widgets add table rows for styling (see the <ahref="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.
<td>When this option is <code>true</code> any applied sort on the table will be reapplied after an update method (<spanclass="version">v2.19.0</span>).
Specifically, this option applies to the <ahref="#updateall"><code>updateAll</code></a>, <ahref="#update"><code>update</code></a>, <ahref="#addrows"><code>addRows</code></a> and <ahref="#updatecell"><code>updateCell</code></a> methods and is checked after the method has completed updating the internal cache.<br>
<spanclass="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>
<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>
<spanclass="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.
</p>
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 <ahref="#sortappend"><code>sortAppend</code></a> option will be applied. More explicitly:<br>
<li><ahref="#sortappend"><code>SortAppend</code></a> is the default sort that is added to the end of the users sort selection (null by default; <spanclass="version updated">v2.24.0</span>).</li>
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>.
<spanclass="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.
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 <ahref="#sortforce"><code>sortForce</code></a> for more details on other sort order options.<br>
<spanclass="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.
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>
sortAppend : [[1,0], [2,0]] // always append sorting of 2nd and 3rd column
});
});</pre>
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 <ahref="#sortforce"><code>sortForce</code></a> for more details on other sort order options.
This sets the direction a column will sort when clicking on the header for the first time. Valid arguments are <code>"asc"</code> for Ascending or <code>"desc"</code> for Descending.<br>
Boolean flag indicating if certain accented characters within the table will be replaced with their equivalent characters. (Modified v2.2).
<divclass="collapsible">
<ul>
<li>This option no longer switches the sort to use the <code>String.localeCompare</code> method.</li>
<li>When this option is <code>true</code>, the text parsed from table cells will convert accented characters to their equivalent to allow the alphanumeric sort to properly sort.</li>
<li>If <code>false</code> (default), any accented characters are treated as their value in the standard unicode order.</li>
<li>The following characters are replaced for both upper and lower case (information obtained from <aclass="external"href="https://sugarjs.com/docs/#/ArraySorting">sugar.js sorting equivalents</a> table):
<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 <ahref="#textsorter"><code>textSorter</code></a> option as follows:
<spanclass="label label-info">NOTE!</span> See the <ahref="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 <ahref="example-locale-sort.html">sortLocaleCompare demo</a>.
<del>Boolean flag indicating whenever to use javascript <code>String.localeCompare</code> method or not.<br>
This is only used when comparing text with international character strings. A sort using localeCompare will sort accented characters the same as their unaccented counterparts.</del>
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).
<divclass="collapsible">
<br>Don't confuse this option with the <ahref="#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.
<td>The key used to reset sorting on the entire table. Defaults to the control key. The other options are <code>"shiftKey"</code> or <code>"altKey"</code> (<aclass="external"href="https://developer.mozilla.org/en/DOM/MouseEvent">reference</a>).</td>
Setting this option to <code>true</code> will start the sort with the <ahref="#sortinitialorder"><code>sortInitialOrder</code></a> when clicking on a previously unsorted column. (v2.0.31).
Setting this option to <code>true</code> and sorting two rows with exactly the same content, the original sort order is maintained (<spanclass="version">v2.14</span>).
This isn't exactly a <aclass="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 <ahref="https://github.com/Mottie/tablesorter/issues/419">issue #419</a>.
The key used to select more than one column for multi-column sorting. Defaults to the <kbd>Shift</kbd> key.
<divclass="collapsible">
<p>The other options include <code>"ctrlKey"</code> or <code>"altKey"</code> (<aclass="external"href="https://developer.mozilla.org/en/DOM/MouseEvent">reference</a>)</p>
To make a multisort always active, use any of the other event objects that are always <aclass="external"href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy">"truthy"</a> like <code>"type"</code> or <code>"bubbles"</code>. See <ahref="https://github.com/Mottie/tablesorter/issues/1200">issue #1200</a>).
<li><code>"max"</code> will treat any text in that column as a value greater than the <em>max</em> (more positive) value. Renamed from "max+".</li>
<li><code>"min"</code> will treat any text in that column as a value greater than the <em>min</em> (more negative) value. Renamed from "max-".</li>
<li><code>"top"</code> will always sort the text to the top of the column.</li>
<li><code>"bottom"</code> will always sort the text to the bottom of the column.</li>
<li><code>"none"</code> or <code>"zero"</code> will treat the text as if it has a value of zero.</li>
Changed to empty string in v2.11, as the <code>"tablesorter"</code> class will always be added to the table; this option now contains any additional class names to add.
<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>
Modify this option if you are not using the default css, or if you are using a completely custom stylesheet.
<td>This option will add a theme css class name to the table <code>"tablesorter-{theme}"</code> for styling (v2.4; <spanclass="version updated">v2.18.0</span>).
<p><spanclass="label label-info">Note</span> the <code>.filtered</code> class can be modified using the <ahref="#widget-filter-filteredrow"><code>filter_filteredRow</code> option</a>.</p>
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:
<p>You will need to use the uitheme widget to extend the theme to apply css from jQuery UI, Bootstrap or other css libraries.</p>
<h4>Modify a theme</h4>
<p>If you want to modify the existing themes ("jui" and "bootstrap"), it can be done as follows:</p>
<p>Modify the class names by extending from the <ahref="#variable-themes"><code>$.tablesorter.themes</code></a> variable</p>
<p><spanclass="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>
<preclass="prettyprint lang-js">// Extend a theme to modify any of the default class names
$.extend($.tablesorter.themes.jui, {
// change default jQuery uitheme icons - find the full list of icons
// here: http://jqueryui.com/themeroller/ (hover over them for their name)
<td>This data-attribute can be added to any tbody cell and can contains alternate cell text (<spanclass="version">v2.16.0</span>).
<divclass="collapsible">
<br>
This option contains the name of the data-attribute used by the <ahref="#textextraction"><code>textExtraction</code></a> function. Add it to the cell(s) as follows:
<spanclass="label label-info">Note</span> This option only works when the <ahref="#textextraction"><code>textExtraction</code></a> option is set to "basic".
<p><spanclass="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> (<ahref="https://github.com/Mottie/tablesorter/issues/983">ref</a>)!</p>
In <spanclass="version updated">v2.19.0</span>, the code was further optimized. When set to <code>"basic"</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.
In <spanclass="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>
<spanclass="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>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
<li>The default text extraction method has been renamed and updated to get data from a data-attribute (set by the <ahref="#textattribute"><code>textAttribute</code></a> option).</li>
<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>
<li>Also, this option can now be set using a data-attribute named "data-text-extraction" on the table.</li>
tablesorter will pass the current table cell object for you to parse and return. Thanks to Josh Nathanson for the examples; updated to a jQuery example by Rob G (Mottie).
<p>Now if the text you are finding in the script above is say a number, then just include the <ahref="#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>
<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>
The built-in option is <code>"basic"</code> (modified v2.16.0) which is the equivalent of doing this inside of the textExtraction function: <code>$(node).text();</code>.
});</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 ).
<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>
<spanclass="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.
<p>Change this option if you're using pointer events (or the <aclass="external"href="https://github.com/jquery/PEP">pointer events polyfill</a>). Add multiple events separated by spaces.</p>
<spanclass="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.
<p>Change this option if you're using pointer events (or the <aclass="external"href="https://github.com/jquery/PEP">pointer events polyfill</a>). Add multiple events separated by spaces.</p>
<spanclass="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.
Replace the default sorting algorithm with a custom one using this option (<spanclass="version updated">v2.27.6</span>) - <spanclass="label label-warning">*NOTE*</span> The parameters have changed!!.
});</pre>In <spanclass="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 <spanclass="version updated">v2.12</span>):
});</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 ).
Initialize widgets using this option ( e.g. <code>widgets : ['zebra']</code>, or custom widgets <code>widgets: ['zebra', 'myCustomWidget'];</code>, see <ahref="example-widgets.html">this demo</a> on how to write your own custom widget ).
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).
<divclass="collapsible">
<br>
Previously documented widget options <ahref="#widgetzebra"><code>widgetZebra</code></a>, <ahref="#widgetcolumns"><code>widgetColumns</code></a> and <ahref="#widgetuitheme"><code>widgetUitheme</code></a> will be retained for backwards compatibility.<br>
<br>
Use the <ahref="#widgetoptions"><code>widgetOptions</code></a> option as follows, please note that each option is followed by a comma (except the last one):
<td>Used by the "checkbox" parser in the <code>parser-input-select.js</code> file (<spanclass="version">v2.22.2</span>; <spanclass="version updated">v2.25.0</span>).
<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>
<p>For example, if the named parser file has been loaded & "sorter-checkbox" class is added to the first column header, then any checked checkbox in the first column will have <code>"checked checked-0"</code> class names added to the row.</p>
<td>Used by the "checkbox" parser in the <code>parser-input-select.js</code> file (<spanclass="version updated">v2.24.6</span>).
<divclass="collapsible">
<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>
<p>If <code>false</code>, same column checkboxes in <em>all</em> rows are modified to match the status of the header checkbox.</p>
This option is meant to be used with the <aclass="external"href="https://github.com/jquery/globalize">jQuery Globalize</a> library along with CLDR data.
<p>See the <ahref="example-widget-grouping.html#globalization">Globalization</a> section in the group widget demo for details on how to set it up.</p>
<p>Currently, the globalize (<code>parser-globalize.js</code>), month (<code>parser-date-month.js</code>) & weekday (<code>parser-date-weekday.js</code>) parsers utilize this option.</p>
Used by the image parser to grab the image attribute content (<spanclass="version">v2.17.5</span>; moved to tablesorter core in <spanclass="version updated">v2.18.0</span>; see <ahref="#parsers"><code>config.parsers</code></a>).
<divclass="collapsible"><br>
Change this setting to grab a different image attribute to be used for sorting:
<preclass="prettyprint lang-js">$(function(){
$('table').tablesorter({
// parse image title (value to be used while sorting & filtering)
imgAttr : 'title',
headers : {
0 : { sorter: 'image' } // this parser is auto-detected, but will only work on the first image
This option is being <spanclass="label label-danger">deprecated</span> in v2.21.3!
It has been replaced by <ahref="#widget-storage-fixed-url"><code>widgetOptions.storage_fixedUrl</code></a>; but is still available for backwards compatibility.
This option was added to set a specific page when storing data using the <ahref="#function-storage"><code>$.tablesorter.storage</code></a> code (<spanclass="version">v2.12</span>).
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>
<br>
The table url & 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><table class="tablesorter" data-table-page="mydomain" data-table-group="financial">...</table></code>)<br>
<br>
For a bit more detail, specifically on how to use the new storage function options for a custom widget, please refer to <ahref="https://github.com/Mottie/tablesorter/issues/389#issuecomment-26594259">issue #389</a>.
When the column styling widget is initialized, it automatically applied the default class names of <code>"primary"</code> for the primary sort, <code>"secondary"</code> for the next sort, <code>"tertiary"</code> for the next sort, and so on (add more as needed)... (v2.0.17).
Used when the ui theme styling widget is initialized. It automatically applies the default class names of <code>"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code>"ui-icon-arrowthick-1-s"</code> for the descending sort and <code>"ui-icon-arrowthick-1-n"</code> for the ascending sort. (v2.0.9).
Find more jQuery UI class names by hovering over the Framework icons on this page: <aclass="external"href="http://jqueryui.com/themeroller/">http://jqueryui.com/themeroller/</a><br>
<br>
Use the <ahref="#widgetuitheme"><code>widgetUitheme</code></a> option to change the css class name as follows:
When the zebra striping widget is initialized, it automatically applied the default class names of <code>"even"</code> and <code>"odd"</code>.
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:
<li>The applied order of widget is dependent of the widget priority, from low to high.</li>
<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>
<li>* The <code>saveSort</code> and <code>resizable</code> widgets use the <ahref="#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>
<li>** The <code>stickyHeaders</code> widget was updated in v2.18.0 to use <code>$.isWindow</code> for the <code>xScroll</code>&<code>yScroll</code> options; and therefore now requires jQuery 1.4.3+.</li>
<spanclass="label label-info">TIP!</span> Click on the link in the property column to reveal full details (or <ahref="#"class="toggleAll">toggle</a>|<ahref="#"class="showAll">show</a>|<ahref="#"class="hideAll">hide</a> all) or double click to update the browser location.
Columns widget: When the column styling widget is initialized, it automatically applied the default class names of <code>"primary"</code> for the primary sort, <code>"secondary"</code> for the next sort, <code>"tertiary"</code> for the next sort, and so on (add more as needed)... (Modified v2.1).
Columns widget: If true, the class names from the <ahref="#widget-columns"><code>columns</code></a> option will also be added to the table thead (v2.4).
Columns widget: If true, the class names from the <ahref="#widget-columns"><code>columns</code></a> option will also be added to the table tfoot (v2.4).
Filter widget: If there are child rows in the table (rows with class name from <ahref="#csschildrow"><code>"cssChildRow"</code></a> option) and this option is <code>true</code> and a match is found anywhere in the child row, then it will make that row visible.
<p><spanclass="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><br></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 (<aclass="external"href="http://perfectionkills.com/the-poor-misunderstood-innerText/">ref</a>).</p>
<p>The <code>filter_childRows</code> option must also be <code>true</code> for this option to work.</p>
<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>
<p></p>
Use the <ahref="#widget-filter-child-by-column"><code>filter_childByColumn</code></a> option as follows:
Filter widget: If <code>true</code>, allows using "#:{query}" in anyMatch searches (<spanclass="version">v2.20.0</span>).
<divclass="collapsible">
<br>
Users can use the anymatch input to target a specific column, using a one-based index.
<p></p>
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.
<p></p>
See live examples in the <ahref="example-widget-filter-any-match.html#anymatch_searches">Filter Widget External Search</a> demo.
<p>Use the <ahref="#widget-filter-cellfilter"><code>filter_cellFilter</code></a> option to add an extra css class name as follows:</p>
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
// css class applied to the table row containing the filters & the inputs within that row
// or [ "filter-cell0", "filter-cell1", "filter-cell2", etc... ]
filter_cellFilter : "tablesorter-filter-cell"
}
});
});</pre><spanclass="label label-info">Note</span> The cells from this option are also contained within the <ahref="#variable-filters"><code>config.$filters</code></a> variable.
Changed default to an empty string in v2.11, as the <code>"tablesorter-filter"</code> class will always be added to the filter; this option now contains any additional class names to add.
<li>Symbols can be added to the beginning <code>"~{query}"</code> (default fuzzy search) or end <code>"{q}="</code> (default exact search)</li>
<li>For example, to add a default "OR" search, use <code>"{q} OR {q}"</code>.</li>
<li>If the user enters <code>"a b c d"</code> the column will be filtered using <code>"a OR b OR c OR d"</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>
<li>If the user only enters <code>"a"</code>, then the column will be filtered using <code>"a OR a"</code> so as not to cause other issues.</li>
<li><spanclass="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>
<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>
These external inputs have one requirement, they must have a <code>data-column="#"</code>, where the <code>#</code> targets the column (zero-based index), pointing to a specific column to search.<br>
Filter widget: This is the class name applied to all rows that do not match the filter (hidden rows); used by pager plugin (<spanclass="version">v2.10</span>).
<spanclass="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!
In <spanclass="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>
<spanclass="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>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
A new file has been included named "widget-filter-formatter-jui.js" & "widget-filter-formatter-html5.js". The files include code to add jQuery UI and HTML5 controls via the <ahref="#widget-filter-formatter"><code>filter_formatter</code></a> option.<br>
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 <ahref="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 <ahref="example-widget-filter-formatter-1.html">example 1</a>).<br>
<br>
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>
<br>
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>
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.
Filter widget: Customize the filter widget by adding a select dropdown with content, custom options or custom filter functions (v2.3.6; <spanclass="version updated">v2.17.0</span>).
In <spanclass="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>
<spanclass="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>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
// set the column value to true, and/or add "filter-select" class name to header
0 : true
}
}
});
});</pre>
Alternately, instead of setting the column filter funtion to true, give the column header a class name of "filter-select". See the <ahref="example-widget-filter-custom.html">demo</a>.<br><br>
</li>
<li>
Make a select dropdown list with custom option settings. Each option must have a corresponding function which returns a boolean value; return true if there is a match, or false with no match.
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 (<spanclass="version">v2.15</span>).
<divclass="collapsible">
<br>
Use the <ahref="#widget-filter-hideempty"><code>filter_hideEmpty</code></a> option as follows:
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; <spanclass="version updated">v2.26.6</span>).
});</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.
In <spanclass="version updated">v2.26.6</span>, this setting can also contain a function.
<li>When this function returns a boolean value, it signifies whether the filter row should or should not be hidden (see the details in <ahref="https://github.com/Mottie/tablesorter/issues/477#issuecomment-229352896">this issue</a>.</li>
<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>
</ul>
Example of function setting:
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_hideFilters : function(config) {
// get an array of filter queries (don't use the value from
// `config.lastSearch` because this code will modify it;
// unless you extend it)
var search = $.tablesorter.getFilters(config.$table);
// ignore any query is column 2 (zero-based index)
search.splice(2,1);
// return true to hide the filter row, false to show it
Filter widget: Set this option to <code>false</code> to make the column content search case-sensitive, so typing in "a" will not find "Albert". (v2.3.4)
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; <spanclass="version updated">v2.27.3</span>).
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>
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.
<p>In <spanclass="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>
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_liveSearch : {
// when false, the user must press enter to blur the input to trigger the search
3 : false,
// the query will initiate when 5 or more characters are entered into the filter
4 : 5,
// no live search on the last three columns (using a header class name)
'.last-3-columns' : false,
// for columns that aren't defined; this will set the fallback value
Filter widget: This option sets the global setting that applied to either input or select filters (<spanclass="version">v2.25.5</span>)
<divclass="collapsible">
<p>A basic input filter will match the filter query until a "and" and "or" type search is performed.</p>
<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>
<p>This option allows you to set a global "match" setting and save you the trouble of adding a bunch of classes.</p>
<p>There are only two options: "exact" and "match"; and it defaults to "exact" if anything else is entered.</p>
In the demo, try searching for <code>super or man</code> in the first column.
Filter widget: If a header contains a select dropdown and this class name, only the available (visible) options in the column will show (<spanclass="version">v2.10.1</span>; <spanclass="version updated">v2.17.6</span>).
In <spanclass="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>
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 <ahref="example-widget-filter-custom.html">custom filter widget</a> demo "Discount" column for an example (sort the "First Name" column first).<br>
<spanclass="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.
Filter widget: Set global filter input placeholder text for search inputs and selects (<spanclass="version">v2.16</span>).
<divclass="collapsible">
<br>
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:
<ul>
<li>Header cell data (<code>table.config.$headers.eq(0).data('placeholder', 'search for...');</code></li>
<spanclass="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>
</pre><spanclass="label label-info">Note:</span> The browser must support the <aclass="external"href="http://caniuse.com/#feat=input-placeholder">placeholder attribute</a> before it will be visible.
When this option points to a reset element using a jQuery selector string, it is bound using <aclass="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>
For example, add this button (<code><button class="reset">Reset</button></code>) to the table header, or anywhere else on the page. That element will be used as a reset for all column and quick search filters (clears all fields):
If this option contains a jQuery object (<spanclass="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>
<br>
If either of these methods do not work as desired, simply trigger a <ahref="#filterreset"><code>filterReset</code> event</a> on the table.
Filter widget: when <code>true</code>, normalize pressing escape to clear filter input across browsers (<spanclass="version">v2.25.2</span>).
<divclass="collapsible">
<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>
When this option is set to <code>false</code>, pressing escape inside the search field is ignored.
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 (<spanclass="version">v2.14</span>).
Filters saved to local storage (or cookies) will override any default filters within the header data-attribute (set by the <ahref="#widget-filter-defaultattrib"><code>filter_defaultAttrib</code> option</a>) and be available to the pager before any ajax calls are made.<br>
Filter widget: Set this option to allow searching through already filtered rows (in special conditions); this will speed up searching in large tables (<spanclass="version">v2.17.4</span>).
<divclass="collapsible">
<br>
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>
<br>
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>
<br>
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>
<br>
The search through filtered results <em>only occurs</em> if the following conditions are met:
<ul>
<li>The last search (for all columns) was not completely empty - all rows will be searched anyway.</li>
<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>
<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>
<li>Or, if the search is using a select dropdown without a "filter-match" class name (looking for an exact match).</li>
<li>If the search does not contain an operator greater than or equal to a negative number (<code>>=-10</code>) or less than or equal to a positive number (<code><=10</code>).</li>
<li>And lastly, only search filtered rows if all rows are not hidden.</li>
</ul>
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>
<br>
Use the <ahref="#widget-filter-searchfiltered"><code>filter_searchFiltered</code></a> option as follows:
Filter widget: Include a function to return an array of values to be added to the column filter select (<spanclass="version">v2.16.0</span>; <spanclass="version updated">v2.24.4</span>).
In <spanclass="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 <ahref="example-widget-filter-selectmenu.html">filter selectmenu demo</a>:
{ value : '/\\.js$/', 'data-class' : 'ui-icon-script', text : 'javascript' },
{ value : '/\\.(jpg|png|gif)$/', 'data-class' : 'ui-icon-image', text : 'Image' },
// plain strings are also acceptable - the string is added to both the text & value attribute
'foobar',
{ value : '.css', 'data-class' : 'ui-icon-note', text : 'CSS' },
{ value : '.html', 'data-class' : 'ui-icon-document', text : 'HTML page' },
{ value : '/\\.(json|txt|md)$/', 'data-class' : 'ui-icon-help', text : 'Misc' },
]
}</pre>
<ul>
<li>Each object entry <em>must</em> include a <code>text</code> property, or it will get ignored.</li>
<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>
<li>Plain strings are still allowed within the array. If included, both the option text & value attribute will contain the string.</li>
<li><spanclass="label warning">*NOTE*</span> when returning an array containing objects, the options will not be reduced to obtain unique selections.</li>
<li><spanclass="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>
In <spanclass="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.
</p>
<p>
In <spanclass="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 <ahref="http://jsfiddle.net/Mottie/856bzzeL/117/">this demo</a> (<aclass="external"href="http://stackoverflow.com/a/29506523/145346">ref</a>).
In <spanclass="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>
<spanclass="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>"th:eq()"</code>, <code>":gt()"</code>, <code>":lt()"</code>, <code>":first"</code>, <code>":last"</code>, <code>":even"</code> or <code>":odd"</code>, <code>":first-child"</code>, <code>":last-child"</code>, <code>":nth-child()"</code>, <code>":nth-last-child()"</code>, etc.<br>
A column will have a filter select dropdown when a "filter-select" class name is added to the header cell, or if the <ahref="#widget-filter-functions"><code>filter_functions</code></a> column value is set to <code>true</code><br>
<br>
This option allows using an alternate source, or customizing options of the filter select dropdown. This option can be set as follows:
<ul>
<li><code>null</code> - this value will set the default behavior and return all table cell values from the current column.</li>
<li>An overall function - when this option is a function, it will be used for all filter selects in the table.
<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.
<p>This example was updated in <spanclass="version">v2.23.4</span> to use the <code>buildSelect</code> function directly (<ahref="https://github.com/Mottie/tablesorter/issues/1010">ref</a>)</p>
<li><code>column</code> - zero-based index of the column with a filter select</li>
<li><code>onlyAvail</code> - boolean indicating if the returned options should only be from available (non-filtered) rows.</li>
</ul>
<spanclass="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.
Filter widget: Set this option to be any separator (<spanclass="version">v2.17.6</span>) that is to be used within the <code>filter_selectSource</code> returned array.
<divclass="collapsible">
<br>
Use the <ahref="#widget-filter-selectsource-separator"><code>filter_selectSourceSeparator</code></a> option as follows:
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
widgets: ["filter"],
widgetOptions : {
filter_selectSource : {
0 : [ 'en|English', 'fr|French', 'de|German' ]
},
// filter_selectSource array text left of the separator is added to the option value, right into the option text
Filter widget: Set this option to <code>true</code> to use the filter to find text from the start of the column, so typing in "a" will find "albert" but not "frank", both have a's. (v2.1).
<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:
<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>
Filter widget: This option contains the name of the data-attribute which contains the default (starting) filter value (<spanclass="version">v2.10.8</span>).
<divclass="collapsible">
<br>
Use the <ahref="#widget-filter-defaultattrib"><code>filter_defaultAttrib</code></a> option as follows:
});</pre>Then add the default filter value to the table header as follows:<preclass="prettyprint lang-html"><th data-value="<30">Age</th></pre></div>
Changed to empty string in v2.11, as the <code>"tablesorter-stickyHeader"</code> class will always be added to the sticky header row; this option now contains any additional class names to add.
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 (<spanclass="version">v2.9</span>).
Sticky Headers widget: If this option is <code>false</code> and a caption exists, it will not be included in the sticky header (<spanclass="version">v2.10.8</span>).
<divclass="collapsible">
<br>
Use the <ahref="#widget-sticky-headers-include-caption"><code>stickyHeaders_includeCaption</code></a> option as follows:
Sticky Headers widget: jQuery selector or object to physically attach the sticky headers (<spanclass="version">v2.27.0</span>).
<divclass="collapsible">
<p>
<spanclass="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!
</p>
Use the <ahref="#widget-sticky-headers-appendto"><code>stickyHeaders_appendTo</code></a> option as follows:<br>
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
widgets: ["stickyHeaders"],
widgetOptions : {
// Where to attach the stickyHeaders
stickyHeaders_appendTo : '.wrapper' // $('.wrapper') jQuery object can also be used
Sticky Headers widget: points to the table wrapper to stick the headers to while scrolling. Use this option to point to their needs (<spanclass="version">v2.14.4</span>).
<divclass="collapsible">
<br>
Use the <ahref="#widget-sticky-headers-attachto"><code>stickyHeaders_attachTo</code></a> option as follows:<br>
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> (<spanclass="version">v2.10</span>).
If the page includes a fixed navigation bar at the top, like Bootstrap, set <ahref="#widget-sticky-headers-offset"><code>"stickyHeaders_offset"</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>
Sticky Headers widget: Scroll table top into view after filtering (<spanclass="version">v2.16.2</span>).
<divclass="collapsible">
<br>
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>
<br>
Set this option to <code>false</code> to prevent the page scroll after filtering the table.
Sticky Headers widget: If <code>true</code>, sticky table headers will resize automatically when content is added to or removed from the table headers (<spanclass="version">v2.10</span>).
<divclass="collapsible">
<br>
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>.
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>
Sticky Headers widget: The zIndex added to the stickyHeaders. This option allows the user to adjust the value to their needs (<spanclass="version">v2.11</span>).
<divclass="collapsible">
<br>
Use the <ahref="#widget-sticky-headers-zindex"><code>stickyHeaders_zIndex</code></a> option as follows:
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).
Resizable widget: If this option is set to <code>true</code>, a resizing anchor will be included in the last column of the table (<spanclass="version">v2.8.3</span>).
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>
Use the <ahref="#widget-resizable-addlastcolumn"><code>"resizable_addLastColumn"</code></a> option to include the last column resizer as follows:
<td>Resizable widget: If this option is set to <code>true</code>, the resizable handle will extend into the table footer (<spanclass="version">v2.28.8</span>).
<divclass="collapsible">
<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>
<p>If <code>false</code>, the resizable handle will not extend into the table footer.</p>
Resizable widget: Set this option to throttle the resizable events (<spanclass="version">v2.17.4</span>).
<divclass="collapsible">
<br>
When <code>false</code> throttling of the mousemove (resizing) event is not applied.<br>
<br>
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>
<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>
<p>When <code>false</code>, resizing a column will move the column border between it's neighbors.</p>
<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>
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).
Storage widget: Set this option to the first letter of the desired storage type (<spanclass="version">v2.28.8</span>).
<divclass="collapsible">
<p>If <em>any</em> value is set in this option, the deprecated <ahref="#widget-storage-use-session-storage"><code>"storage_useSessionStorage"</code></a> is completely ignored.</p>
<ul>
<li>When set to <code>"s"</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>
<li>When set to <code>"c"</code> (cookie), all saved variables for the table will use cookies.</li>
<li>Any other setting will switch to using the default <code>localStorage</code> type.</li>
</ul>
Use the <ahref="#widget-storage-storage-type"><code>"storage_storageType"</code></a> option as follows:
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
widgets: ["saveSort"],
widgetOptions : {
// This sets session storage; only the first letter is required
<p>In <spanclass="version">v2.28.8</span>, this option is replaced by the <ahref="#widget-storage-storage-type"><code>"storage_storageType"</code></a> option and will be completely ignored if that option has <em>any</em> setting.</p>
<p>If this option is set to <code>false</code>, all saved variables for the table will be within local storage (<spanclass="version">v2.21.3</span>).</p>
<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>
Use the <ahref="#widget-storage-use-session-storage"><code>"storage_useSessionStorage"</code></a> option to switch to session storage as follows:
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
widgets: ["saveSort"],
widgetOptions : {
// if false, saved variables will be saved in local storage
Storage widget: This option allows setting an alternate table id so multiple tables on a page have the settings grouped together
<divclass="collapsible">
<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>
<p>If this option is not defined, the actual table id will be used (which isn't conducive to applying to multiple tables!)</p>
<p>A more detailed list of the table id priority settings can be found in the <ahref="#function-storage"><code>$.tablesorter.storage</code></a> function description.</p>
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.
<divclass="collapsible">
<p>If a value is set in this option, the storage widget looks in that defined table data-attribute for a table id.</p>
<p>The value in the data-attribute sets a table id, if not found, the storage widget then looks for an id in the <ahref="#widget-storage-table-id"><code>storage_tableId</code></a> option.</p>
<p>A more detailed list of the table url priority settings can be found in the <ahref="#function-storage"><code>$.tablesorter.storage</code></a> function description.</p>
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.
<divclass="collapsible">
<p>If a value is set in this option, the storage widget looks in that defined table data-attribute for a table url.</p>
<p>The value in the data-attribute sets a table url, if not found, the storage widget then looks for a url in the <ahref="#widget-storage-fixed-url"><code>storage_fixedUrl</code></a> option.</p>
Zebra widget: When the zebra striping widget is initialized, it automatically applied the default class names of <code>"even"</code> and <code>"odd"</code>. (Modified v2.1).
<spanclass="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>"tablesorter-pager"</code>)<br>
This is some example pager markup. It <em>should</em> contain all of the controls set by the multiple css-named options:<preclass="prettyprint lang-html">
</div></pre><spanclass="label label-warning">Caution</span> If you use buttons in your pager container, make sure the buttons include a button type (<code><button type="button">Next</button></code>) to prevent form submission and page reloading every time the button is clicked.<br>
<br>Use this option as follows:<preclass="prettyprint lang-js">$(function(){
Set this option to include a url template to use so that the pager plugin can interact with your database (v2.1; <spanclass="version updated">v2.9</span>).
<spanclass="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>
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:
If you need to send your server a page offset (actual starting record number), then you'll need to use the <ahref="#pager-customajaxurl"><code>customAjaxUrl</code> option</a>.<br>
<tr><td><code>{page+1}</code></td><td>One-based index of the current pager page (replace "+1" with any number) (e.g. <code>{page+3}</code>) (<spanclass="version">v2.9</span>).</td></tr>
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>"&sort[2]=0&sort[3]=0"</code> in the url. <code>{sort:col}</code> shortened tag also works (<spanclass="version">v2.9</span>).
<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>
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>"&fcol[2]=Blue&fcol[3]=13"</code> in the url. <code>{filter:col}</code> shortened tag also works (<spanclass="version updated">v2.9</span>).
<spanclass="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>
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).
In the following example, lets say your server needs a starting and ending record number instead of a page & size parameter. Use this option as follows:
<spanclass="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>
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>
Your server does not need to return a JSON format, if you want to return pure HTML, set the dataType to <code>"html"</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>
This callback allows you to customize the error message displayed in the <code>thead</code> (<spanclass="version">v2.23.0</span>; <spanclass="version updated">v2.23.1</span>).
<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 <aclass="external"href="http://api.jquery.com/ajaxError/">.ajaxError()</a> method.</li>
<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>
<spanclass="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>
When there is an ajax error, the <ahref="#function-showError"><code>$.tablesorter.showError</code></a> function is called. In <spanclass="version">v2.23.0</span>, that function now checks this callback to allow adding a custom error message.<br>
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 (<spanclass="version">v2.25.4</span>).
<divclass="collapsible">
<br>
<spanclass="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_initialRows</code>
Set this option to <code>false</code> if your table data is preloaded into the table, but you are still using ajax (<spanclass="version">v2.14.5</span>).
<spanclass="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_processAjaxOnInit</code>
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, <spanclass="version updated">v2.17.3</span>).
<spanclass="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>
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>
There are numerous examples below. Choosing which one to use is left to you. For more information, please check out related questions on <aclass="external"href="http://stackoverflow.com/search?q=%5Btablesorter%5D+ajaxProcessing">Stackoverflow</a>, in particular see <aclass="external"href="http://stackoverflow.com/q/16783740/145346">this thread</a> about how to use the different ajax options together.<br>
In <spanclass="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>
Process your ajax data so that the following information is returned:<br>
<br>
<divclass="accordion">
<h3><ahref="#">Object</a></h3>
<div>
After tablesorter <spanclass="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>
<br>
After tablesorter <spanclass="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 <ahref="https://github.com/Mottie/tablesorter/issues/326#issuecomment-25326546">issue #326</a>);<br>
<br>
So, lets say the data sent by the server looks like this:
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.
]</pre><spanclass="label label-info">Note</span>: In <spanclass="version">v2.14.3</span>, the contents of the array can also contain table cell markup (i.e. <code>"<td class='green'>+ 10%</td>"</code>).<br>
Here is some example JSON (comments added, but not allowed in JSON) which is contained in the <ahref="https://github.com/Mottie/tablesorter/blob/master/docs/assets/City0.json">City0.json</a> file:
<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; <spanclass="version updated">v2.28.4</span>).
<spanclass="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>
<p>The <ahref="#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>
<preclass="prettyprint lang-html"><span class="pagedisplay" data-pager-output="{startRow:input} – {endRow} / {totalRows} total rows" data-pager-output-filtered="{startRow:input} – {endRow} / {filteredRows} of {totalRows} total rows"></span></pre>
<p>It will not override this option if set as a function, or if a specific <ahref="#object">output is returned</a> from the server through ajax.</p>
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>
<spanclass="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>
Set the starting page of the pager (zero-based index).
<divclass="collapsible">
<br>
<spanclass="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_startPage</code>
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 (<spanclass="version updated">v2.16</span>).
<divclass="collapsible">
<br>
<spanclass="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_pageReset</code>
Set initial number of visible rows. This value is changed by the dropdown selector targeted by the <ahref="#pager-csspagesize"><code>cssPageSize</code></a> option.
<divclass="collapsible">
<br>
<spanclass="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_size</code>
Saves the current pager page size and number. This option requires the <ahref="#function-storage"><code>$.tablesorter.storage</code></a> script in the <code>jquery.tablesorter.widgets.js</code> file (<spanclass="version">v2.11</span>).
<divclass="collapsible">
<br>
<spanclass="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_savePages</code>
Saves tablesorter paging to custom key if defined. Key parameter name used by the <ahref="#function-storage"><code>$.tablesorter.storage</code></a> function. Useful if you have multiple tables defined (<spanclass="version">v2.15</span>)
<divclass="collapsible">
<br>
<spanclass="label label-info">Note</span> The pager widget equivalent option is within the <code>widgetOptions</code> and accessed via <code>widgetOptions.pager_storageKey</code>
<spanclass="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>
This option replaced the original <code>positionFixed</code> and <code>offset</code> options which set the absolute position of the pager block.<br>
<br>
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.
<spanclass="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>
<spanclass="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
<spanclass="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>
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>
<br>
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.
This option contains a jQuery selector string pointing to the go to first page arrow. See <ahref="#pager-container"><code>container</code></a> for full HTML.
<divclass="collapsible">
<br>
<spanclass="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>
This option contains a jQuery selector string pointing to the go to previous page arrow. See <ahref="#pager-container"><code>container</code></a> for full HTML.
<divclass="collapsible">
<br>
<spanclass="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>
This option contains a jQuery selector string pointing to the go to next page arrow. See <ahref="#pager-container"><code>container</code></a> for full HTML.
<divclass="collapsible">
<br>
<spanclass="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>
This option contains a jQuery selector string pointing to the go to last page arrow. See <ahref="#pager-container"><code>container</code></a> for full HTML.
<divclass="collapsible">
<br>
<spanclass="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>
<td>This option contains a jQuery selector string pointing to the page select dropdown. See <ahref="#pager-container"><code>container</code></a> for full HTML (v2.4; <spanclass="version updated">v2.17.3</span>)
<spanclass="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 <spanclass="version updated">v2.17.3</span>)<br>
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 <ahref="#pager-size"><code>size</code></a> setting.
<spanclass="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>
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).
This option contains a jQuery selector string pointing to the page size selector. See <ahref="#pager-container"><code>container</code></a> for full HTML.
<divclass="collapsible">
<br>
<spanclass="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>
<spanclass="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>
<spanclass="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>
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>
Show any rows that match a search query. If this option is <code>true</code> any column match will show that row; but <ahref="example-widget-filter-any-match.html#limitations">there are limitations</a> (<spanclass="version">v2.13.3</span>).<br>
This option contains the name of the theme. Currently jQuery UI ("jui") and Bootstrap ("bootstrap") themes are supported (updated v2.4)
<p>
<spanclass="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 <ahref="#theme"><code>theme</code></a> option.
</p>
<p>To modify the class names used, extend from the <ahref="#variable-themes"><code>$.tablesorter.themes</code></a> variable as follows:</p>
<preclass="prettyprint lang-js">// Extend the themes to change any of the default class names ** NEW **
$.extend($.tablesorter.themes.jui, {
// change default jQuery uitheme icons - find the full list of icons
// here: http://jqueryui.com/themeroller/ (hover over them for their name)
This widget option replaces the previous <ahref="#widgetuitheme">widgetUitheme</a>. All theme css names are now contained within the <code>$.tablesorter.themes</code> variable. Extend the default theme as seen above.<br>
<br>
The class names from the <code>$.tablesorter.themes.{name}</code> variable are applied to the table as indicated.<br>
<br>
As before the jQuery UI theme applies the default class names of <code>"ui-icon-arrowthick-2-n-s"</code> for the unsorted column, <code>"ui-icon-arrowthick-1-s"</code> for the descending sort and <code>"ui-icon-arrowthick-1-n"</code> for the ascending sort. (Modified v2.1; Updated in v2.4). Find more jQuery UI class names by hovering over the Framework icons on this page: <aclass="external"href="http://jqueryui.com/themeroller/">http://jqueryui.com/themeroller/</a><br>
<br>
Use the <ahref="#widget-uitheme"><code>"uitheme"</code></a> option to change the css class name as follows:
<preclass="prettyprint lang-js">$(function(){
$("table").tablesorter({
theme : 'jui', // set theme name from $.tablesorter.themes here
widgets : ["uitheme"], // initialize ui theme styling widget of the table
widgetOptions: {
uitheme : "jui" // this is now optional in v2.7, it is overridden by the theme option
}
});
});</pre>
To add a new theme, define it as follows; replace "custom" with the name of your theme:
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>
Pager: This option was <spanclass="label label-danger">removed</span>! Use the <ahref="#pager-output">output</a> option to allow for more control over the formatting.
The original tablesorter pager plugin would combine the current page with the calculated total number of pages within the <ahref="#pager-csspagedisplay">cssPageDisplay</a> with this separator string inbetween.</div>
<spanclass="label label-info">TIP!</span> Click on the link in the method column to reveal full details (or <ahref="#"class="toggleAll">toggle</a>|<ahref="#"class="showAll">show</a>|<ahref="#"class="hideAll">hide</a> all) or double click to update the browser location.
Also, use this method to add table rows while using the pager plugin. If the "update" method is used, only the visible table rows continue to exist.
<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.
<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>
</ul>
</li>
<li>In <spanclass="version">v2.16.1</span>, the <code>$row</code> parameter can be a row DOM element or jQuery object.</li>
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>
However, it will not clear any values that were saved to storage. This method is basically like reloading the page.
$('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>).
<spanclass="label label-warning">*NOTE*</span> using this method to sort ignores the additions from the <ahref="#sortforce"><code>sortForce</code></a> and <ahref="#sortappend"><code>sortAppend</code></a> options.<br>
<br>
In <spanclass="version updated">v2.17.0</span>, the sort direction can be set using "a" (ascending), "d" (descending), "n" (next), "s" (same) & "o" (opposite).
<td>Update the <code>tbody</code>'s stored data (<code>update</code>&<code>updateRows</code> do exactly the same thing; <spanclass="version updated">v2.23.0</span>)
<divclass="collapsible">
<h4>Direct method:</h4>
<p>In <spanclass="version">v2.23.0</span>, this method can be called directly as follows:</p>
<spanclass="label label-info">NOTE</span> Don't confuse this method with the <ahref="#sortreset"><code>sortReset</code> option</a>. <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 <ahref="https://github.com/Mottie/tablesorter/issues/217">issue #217</a> for more details.
<td>Update a column of cells (<code>thead</code> and <code>tbody</code>) (<spanclass="version">v2.8</span>; <spanclass="version updated">v2.23.0</span>).
<td>Update the parsers, only if not defined, then update the internal cache (<spanclass="version">v2.15.4</span>; <spanclass="version updated">v2.27.0</span>).
<p><spanclass="label label-warning">*NOTE*</span> In <spanclass="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>
This method was originally designed to be used with the pager. It should be used under these conditions:
<ul>
<li>When the pager <code>removeRows</code> option is <code>true</code>.</li>
<li>When not using the "updateCell" or "addRows" methods.</li>
<li>Before manually adding or removing table rows.</li>
<li>And, before triggering an "update".</li>
</ul>
Note: The entire table is stored in the cache, but when using the pager with the <ahref="#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.
<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 (<spanclass="version updated">v2.25.4</span>).
<p>In <spanclass="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>
<p>In <spanclass="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>
<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; <spanclass="verison updated">v2.19.0</span>).
<li>If <code>doAll</code> is <code>true</code> it removes all widgets from the table. If <code>false</code> only non-current widgets (from the <code>widgets</code> option) are removed.</li>
<li>When done removing widgets, the widget re-initializes the currently selected widgets, unless the <code>dontapply</code> parameter is <code>true</code> leaving the table widget-less.</li>
<li>Note that if the <code>widgets</code> option has any named widgets, they will be re-applied to the table when it gets resorted. So if you want to completely remove all widgets from the table, also clear out the widgets option <code>$('table')[0].config.widgets = [];</code></li>
In <spanclass="version updated">v2.15</span>, one additional parameter can be added to the array to perform an "any-match" of the table; <spanclass="label label-warning">Warning!</span> please note that if no external input (with a <code>data-column="all"</code> is attached using <ahref="#function-bindsearch"><code>bindSearch</code></a> function) is visible, the user will not know that a filter has been applied. <preclass="prettyprint lang-js">// in a table with 4 columns; set the 5th parameter to any-match
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.
<td>filter: Trigger the filter widget to reset the sort & reset the search criteria (<spanclass="version">v2.28.7</span>).
<divclass="collapsible">
<p>
This combination reset was added to prevent issues with the widgets not being updated after a combination of <ahref="#filterreset"><code>filterReset</code></a> and <ahref="#sortreset"><code>sortReset</code></a> due to internal timers preventing multiple widget applications in a row.
</p>
This method does not include a callback parameter similiar to the <code>sortReset</code> method.
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
<preclass="prettyprint lang-js">$(function(){
$('table').trigger('pageAndSize', [ 2, 20 ]); // pass a one-based page index & page size
In <spanclass="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.
<td>Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16; <spanclass="version updated">v2.23.0</span>).
<p>In <spanclass="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>
<p>In <spanclass="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>
<p>In <spanclass="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>
<spanclass="label label-info">TIP!</span> Click on the link in the event column to reveal full details (or <ahref="#"class="toggleAll">toggle</a>|<ahref="#"class="showAll">show</a>|<ahref="#"class="hideAll">hide</a> all) or double click to update the browser location.
});</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>
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.
<preclass="prettyprint lang-js">$(function(){
// initialize the tablesorter plugin
$('table')
.tablesorter()
// bind to sort events
.bind('tablesorter-ready', function(e, table) {
// do something after tablesorter has finished interacting with the table;
<td>This event fires after tablesorter has completed executing the <ahref="#refreshwidgets">refreshWidget</a> method (<spanclass="version">v2.19.0</span>)
You can use this event to modify the filter elements (row, inputs and/or selects) as desired. Use it as follows:<preclass="prettyprint lang-js">$(function(){
});</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>
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:<preclass="prettyprint lang-js">$(function(){
});</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>
<td>This event fires when the pager plugin has completed initialization (<spanclass="version">v2.18.1</span>), and its render of the table on the currently selected page. (v2.0.7).
<spanclass="label label-info">Note</span> In <spanclass="version">v2.18.1</span>, the "pagerComplete" event also fires off immediately after pager initialization.<br>
});</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>
});</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>
This event may fire before the <code>pagerComplete</code> event when ajax processing is involved, or after the <code>pagerComplete</code> on normal use.
See <ahref="https://github.com/Mottie/tablesorter/pull/153">issue #153</a>.
tablesorter has some useful internal variables & functions available through the API which can be used in custom coding, parsers and/or widgets.<br>
<h4>Variables</h4>
<spanclass="label label-info">TIP!</span> Click on the link in the variable column to reveal full details (or <ahref="#"class="toggleAll">toggle</a>|<ahref="#"class="showAll">show</a>|<ahref="#"class="hideAll">hide</a> all) or double click to update the browser location.
<td>This object contains all of the default settings shown in the <ahref="#Configuration">configuration</a> section.
<divclass="collapsible">
<p>
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!).
</p>
<spanclass="label warning">Note</span>: If you wish to modify this object, make sure to either target the setting directly: <preclass="prettyprint lang-js">
Or use jQuery extend (include <code>true</code> parameter for <ahref="http://api.jquery.com/jQuery.extend/#jQuery-extend-deep-target-object1-objectN">more depth</a>): <preclass="prettyprint lang-js">
// Extend the object. Use `true` for more than one level of depth
$.extend( true, $.tablesorter.defaults, {
theme: 'myCustomTheme',
widgets: ['zebra', 'filter'],
widgetOptions: {
filter_placeholder: {
search: 'Find in column...',
select: 'Choose an option'
},
zebra: [ 'row-even', 'row-odd' ]
}
});</pre>
If you don't use one of the above methods, the other default settings will be removed and cause unexpected issues.
<td>This is an object containing a list of specific class names to be applied to table elements. Please see the widget <ahref="#widget-uitheme"><code>uitheme</code></a> option for more details. </td>
<td>This object contains the phrases (in English by default) added to the <code>aria-label</code> on each header column (<spanclass="version updated">v2.24.4</span>).
<p>In <spanclass="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>
If the next click were to reset the sort (<code>sortReset</code> applied), then the message would use <code>$.tablesorter.language.nextNone</code>.<br>
<td>This variable contains all instance methods of the config object. Added using <ahref="#function-addInstanceMethods"><code>addInstanceMethods</code></a> function before table initialization (<spanclass="version">v2.21.0</span>).
<li>tbody index (<strong>non-info block only</strong>, indexing now matches the <ahref="#variable-tbodies"><code>config.$tbodies</code></a> variable; <spanclass="version updated">v2.20.0</span>)
<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>
<li>In <spanclass="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
<li>Well not removed, but moved into the row data, within the normalized section of the cache as described above.</li>
<li><del>This contains an array of jQuery row objects</del>.</li>
<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>
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>
<br>
Note that the <code>table.config.columns</code> variable does not always correlate with the indexing of the headers stored within <ahref="#variable-headers"><code>table.config.$headers</code></a> because of multiple rows and column or row spans.
This HTML snapshot is taken using the <ahref="#variable-headers"><code>$headers</code></a> jQuery object, and done before the <ahref="#headertemplate"><code>headerTemplate</code></a> is applied and before the <ahref="#onrendertemplate"><code>onRenderTemplate</code></a> and <ahref="#onrenderheader"><code>onRenderHeader</code></a> callbacks are executed.<br>
<br>
This list is used by the <code>$.tablesorter.restoreHeaders</code> function to restore the table headers when the <ahref="#destroy"><code>destroy</code></a> method is executed.
<td>Internal list of each header element as selected using jQuery selectors in the <ahref="#selectorheaders"><code>selectorHeaders</code></a> option.
<divclass="collapsible">
<br>
This list contains DOM elements (not jQuery objects of each table header cell like the <ahref="#variable-headers"><code>$headers</code></a> variable) and is how the original version of tablesorter stored these objects.
<br>
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.
<td>Internal list of all of the table's currently set parsers (objects copied from <ahref="#variable-parsers"><code>$.tablesorter.parsers</code></a>). Here is a complete list of default parsers: (modified v2.18.0)
<tr><th><code>parser: false</code></th><td>disable parsing for this column (this also disables sorting & filtering for the column; <spanclass="version updated">v2.17.6</span>).</td></tr>
<tr><th><code>sorter: "image"</code></th><td>Sort by image alt value (see <ahref="#imgattr"><code>imgAttr</code></a> option; added in v2.18.0).</td></tr>
<tr><th><code>sorter: "ipAddress"</code></th><td>Sort by IP Address; <spanclass="label label-warning">Warning</span> This parser was moved to the <code>parser-network.js</code> file in <spanclass="version updated">v2.18.0</span>.</td></tr>
<tr><th><code>sorter: "url"</code></th><td>Sort by url.</td></tr>
<tr><th><code>sorter: "isoDate"</code></th><td>Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD; these formats can be followed by a time).</td></tr>
<tr><th><code>sorter: "percent"</code></th><td>Sort by percent.</td></tr>
<tr><th><code>sorter: "usLongDate"</code></th><td>Sort by date (U.S. Standard, e.g. Jan 18, 2001 9:12 AM or 18 Jan 2001 9:12 AM (new in v2.7.4)).</td></tr>
<tr><th><code>sorter: "shortDate"</code></th><td>Sort by a shortened date (see <ahref="#dateformat"><code>dateFormat</code></a>; these formats can also be followed by a time).</td></tr>
<tr><th><code>sorter: "time"</code></th><td>Sort by time (23:59 or 12:59 pm).</td></tr>
<tr><th><code>sorter: "metadata"</code></th><td>Sort by the sorter value in the metadata - requires the metadata plugin.</td></tr>
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).
<p></p>
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.
<p></p>
To make that description less confusing, look at the HTML in the <ahref="#variable-headers"><code>config.$headers</code></a> documentation, only the four middle rows (header-index 1-4) will be contained within this variable:
<preclass="prettyprint lang-js">// the resulting config.$headerIndexed for the HTML example in config.$headers will look like this:
<spanclass="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.
<spanclass="label label-info">*NOTE*</span> The header cells within rows with the <ahref="#cssignorerow"><code>cssIgnoreRow</code></a> class (default is <code>"tablesorter-ignoreRow"</code> will not be included in this variable.</p>
<p>Header cells in not-ignored rows are targeted using the jQuery selector from the <ahref="#selectorheaders"><code>selectorHeaders</code></a> option</p>
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:
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="1"]')</code> or <code>table.config.$headers.eq(2)</code>.<br>
<br>
The <code>table.config.$headers</code> variable is useful within callback functions or when writing widgets that target the table header cells.
<td>Internally stored DOM table element (<spanclass="version">v2.17.5</span>)
<divclass="collapsible">
<br>
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.
lockedOrder: false // true if column order is locked (read only)
}]</pre>
<ul>
<li><code>count</code>
<ul>
<li>The initial value is <code>-1</code>.</li>
<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>
</ul>
</li>
<li><code>order</code>
<ul>
<li>An array that contains the sort sequence for each column.</li>
<li><code>0</code> indicates an ascending sort.</li>
<li><code>1</code> indicates a descending sort.</li>
<li><code>0</code> indicates a reset sort (initial unsorted rows).</li>
<li>Locked sorts will contain either <code>[0, 0]</code> or <code>[1, 1]</code> determined by the lockedOrder setting.</li>
<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>
<li>The values of this order can only be modified <em>after</em> tablesorter has initialized.</li>
</ul>
</li>
<li><code>lockedOrder</code>
<ul>
<li>See the <ahref="#headers">lockedOrder</a> setting.</li>
<li>It's readonly because it is set during initialization and not used again (future use by a widget?)</li>
<spanclass="label label-warning">Caution!</span> These tbodies are the ones without a class name from the <ahref="#cssinfoblock"><code>cssInfoBlock</code></a> option, so the indexing of this jQuery object does not match the actual table tbody indexes.<br>
<td>Boolean value indicating that tablesorter has been initialized on a table
<divclass="collapsible">
<br>
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>
<br>
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.
<td>This variable contains the total number of rows within the table, not including rows within info-only tbodies (<spanclass="version">v2.17.4</span>; <spanclass="version updated">v2.17.5</span>)
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:
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:
<td>Only available when the filter widget is active. This variable contains all external search inputs with <code>data-column="all"</code>, bound using the <ahref="#function-bind-search"><code>bindSearch</code></a> function.
The <code>table.config.widgetOptions.filter_$anyMatch</code> variable contains one more more search inputs, and is dynamically updated if the <ahref="#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.
<td>Only available when the filter widget is active. This variable contains all table cells within the filter row.
<divclass="collapsible">
<br>
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 <ahref="#widget-filter-formatter"><code>filter_formatter</code></a> function allows adding other types of value selectors (e.g. jQuery UI slider).
<td>Only available when the filter widget is active. This variable contains all external search inputs bound using the <ahref="#function-bind-search"><code>bindSearch</code></a> function.
<divclass="collapsible">
<br>
The <code>table.config.widgetOptions.filter_$externalFilters</code> variable contains an array of jQuery objects pointing to all external inputs, even if the <ahref="#function-bind-search"><code>bindSearch</code></a> function is used multiple times.
<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>
<td>Only available when the filter widget is active. This variable contains the current number of filtered rows (<spanclass="version">v2.17.4</span>; <spanclass="version updated">v2.17.5</span>)
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:
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:
<td>Only available when the stickyHeaders widget (not the css3 version) is active.
<divclass="collapsible">
<br>
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>"containsStickyHeaders"</code> versus the original table with a class name of <code>"hasStickyHeaders"</code>.
<thclass="nobold">Access the pager options<sup><strong>†</strong></sup> (<code>p</code>) using any of these methods:
<divclass="collapsible">
<br>
<preclass="prettyprint lang-js">// pure js, get the first table (zero index)
var p = document.getElementsByTagName('table')[0].config.pager;
// or by table ID
var p = document.getElementById('mytable').config.pager;
// using jQuery, get first table (zero index)
var p = $('table')[0].config.pager;
// or from the jQuery data
var p = $('#mytable').data('tablesorter').pager;
</pre>
<strong>†</strong> These methods are the same for both the pager addon and the pager widget.
<p></p>
<spanclass="label label-info">*NOTE*</span> This pager variable also contains all of the default pager option settings.
<p></p>
<spanclass="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.
<td>Contains a jQuery object pointing to a pager block(s).
<divclass="collapsible">
<br>
The <code>table.config.pager.$container</code> variable is targeted using the pager <ahref="#pager-container"><code>container</code></a> option and will have a class name of <code>"tablesorter-pager"</code> applied.<br>
<br>
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.
</div>
</td>
<td></td>
</tr>
<trid="variable-pager-goto">
<td><ahref="#"class="permalink">p.$goto</a></td>
<td>jQuery Object</td>
<td>Contains a jQuery object pointing to an empty select within the pager block(s).
<divclass="collapsible">
<br>
The <code>table.config.pager.$goto</code> variable is targeted using the pager <ahref="#pager-cssgoto"><code>cssGoto</code></a> option.<br>
<br>
The contents of this select element are dynamically updated if the page size is changed or if the table gets filtered.
<td>Contains a jQuery object pointing to a select with the desired page size settings already in place.
<divclass="collapsible">
<br>
The <code>table.config.pager.$size</code> variable is targeted using the pager <ahref="#pager-csspagesize"><code>cssPageSize</code></a> option.<br>
<br>
The contents of this select element must be set up with the desired page size settings before initializing tablesorter.<br>
<br>
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:
<td>Contains an array of zero-based row indexes of rows that currently displayed within the table.
<divclass="collapsible">
<br>
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:
<preclass="prettyprint lang-js">var c = $('table')[0].config,
p = c.pager,
cache = c.cache[0].normalized,
cachedValues = [];
$.each( p.cacheIndex, function(i, v) {
// cache[v] will be an array of parsed values for each cell in selected row
cachedValues.push( cache[v] );
});</pre>
the <code>p.cacheIndex</code> variable get updated whenever the table is sorted, filtered or the pager changes pages or page size.
<td>Contains a one-based index of the first row visible in the pager.
<divclass="collapsible">
<br>
The <code>{startRow}</code> tag in the pager <ahref="#pager-output"><code>output</code></a> option is replaced by this value; and it does not correspond to the row index within the cache.
</div>
</td>
<td></td>
</tr>
<trid="variable-pager-endrow">
<td><ahref="#"class="permalink">p.endRow</a></td>
<td>Numeric</td>
<td>Contains a one-based index of the last row visible in the pager.
<divclass="collapsible">
<br>
The <code>{endRow}</code> tag in the pager <ahref="#pager-output"><code>output</code></a> option is replaced by this value; and it does not correspond to the row index within the cache.
<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.
<divclass="collapsible">
<br>
The <code>{filteredPages}</code> tag in the pager <ahref="#pager-output"><code>output</code></a> option is replaced by this value.
Initially, this value is set by either the pager <ahref="#pager-page"><code>page</code></a> option or from local storage if the <ahref="#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 <ahref="#pager-cssgoto"><code>cssGoto</code></a> option or programmically by the <ahref="#pageset"><code>pageSet</code></a> or <ahref="#pageandsize"><code>pageAndSize</code></a> method.
Initially, this value is set by either the pager <ahref="#pager-size"><code>size</code></a> option or from local storage if the <ahref="#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 <ahref="#pager-csspagesize"><code>cssPageSize</code></a> option or programmically by the <ahref="#pagesize"><code>pageSize</code></a> or <ahref="#pageandsize"><code>pageAndSize</code></a> method.
<td>Internal list of <strong>all</strong> extra table header cells (<spanclass="version">v2.16.2</span>; <spanclass="label label-danger">removed</span> v2.21.3)
<divclass="collapsible">
<p>This variable was removed due to it causing memory leak issues. To now find extra headers use <ahref="#namespace"><code>config.namespace</code></a> as follows:</p>
<p>When the <ahref="#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 (<ahref="#variable-headers"><code>config.$headers</code></a>).</p>
<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>
<td>Internal list of <strong>all</strong> extra (cloned) table elements (<spanclass="version">v2.19.0</span>; <spanclass="label label-danger">removed</span> v2.21.3)
<divclass="collapsible">
<p>This variable was removed due to it causing memory leak issues. To find extra tables use <ahref="#namespace"><code>config.namespace</code></a> as follows:</p>
<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>
<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>
<spanclass="label label-info">TIP!</span> Click on the link in the function column to reveal full details (or <ahref="#"class="toggleAll">toggle</a>|<ahref="#"class="showAll">show</a>|<ahref="#"class="hideAll">hide</a> all) or double click to update the browser location.
<td>This function adds a <code>colgroup</code> element to the table when <ahref="#widthfixed"><code>widthFixed</code></a> is <code>true</code>.
<divclass="collapsible"><br>
A new <code>colgroup</code> with <code>col</code> elements is only added if:
<ul>
<li><ahref="#widthfixed"><code>widthFixed</code></a> is <code>true</code>.</li>
<li>A predefined <code>colgroup</code> element does not already exist in the table *.</li>
</ul>
* <spanclass="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>
<br>
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>
<li><code>getIt</code> - Boolean flag (optional if <code>false</code>).</li>
</ul>
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.
<br>
Here is a basic example of how this function is used:
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.
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>
<br>
All this function does is add or remove a class name of <code>"tablesorter-processing"</code> and the class name contained within the <ahref="#cssprocessing"><code>cssProcessing</code> option</a>.<br>
<br>
Here is a basic example of how this function is used:
Please note that currently the processing icons do not animate (see <ahref="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 & rebuild the table and thus it has no time for animation. If someone knows of a better solution, please share!
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
</ul>
Please note that this function uses jQuery <code>empty()</code>. All data & event handlers are removed. No where within the tablesorter script or included widgets is this function used, it is left intact for backwards compatibility.
This function 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 (> 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>
<br>
To ensure the columns match the original table, include <code>data-column</code> attributes pointing to the desired column.<br>
<br>
Here is a basic example of how this function is used:
In <spanclass="version">v2.16.2</span>, this function now saves all extra (external) headers to the <ahref="#variable-extra-headers"><code>config.$extraHeaders</code></a> variable which allows the plugin to automatically update the sort status.
The original header cell content is saved, within the <ahref="#variable-headercontent"><code>headerContent</code></a> variable array, before the <ahref="#headertemplate"><code>headerTemplate</code></a> is applied and before the <ahref="#onrendertemplate"><code>onRenderTemplate</code></a> and <ahref="#onrenderheader"><code>onRenderHeader</code></a> callbacks are executed.<br>
<li><code>table</code> - table DOM element (or jQuery object) of table.</li>
</ul>
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.
<li><code>callback</code> - Function executed once tablesorter has been removed.</li>
</ul>
When calling the function, set the <code>removeClasses</code> option to <code>true</code> to include removing of the <code>"tablesorter"</code> class name, tablesorter theme name (e.g. <code>"tablesorter-blue"</code>) and the class name applied by the <ahref="#tableclass"><code>tableClass</code> option</a>. The callback function only provides a <code>table</code> (DOM element only) parameter.<br>
<br>
Here is a basic example of how this function is used:
alert('tablesorter has been removed! No sort for you!');
});</pre>
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.
This function is used when the <ahref="#sortlocalecompare"><code>sortLocaleCompare</code></a> option is set to <code>true</code>. Please refer to the option and <ahref="example-locale-sort.html">the demo</a> for more details on the defaults values and how to add more accented characters.
<td>This function returns a zero-based index value of the position of the value within the array, otherwise it returns -1 (Modified <spanclass="version updated">v2.15.6</span>).
<li><code>value</code> - value to find within the array.</li>
<li><code>array</code> - array (sortList) to search for the value.</li>
</ul>
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:
After <spanclass="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.
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 <ahref="example-parsers.html">writing custom parsers</a> demo page for more details & an example.
<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>
<li><code>table</code> - table element or jQuery object of the selected table.</li>
<li><code>'mywidget'</code> - ID of the widget to check.</li>
</ul>
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>
In <spanclass="version updated">v2.19.0</span>, a <code>"refreshing"</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 <ahref="example-widgets.html">this demo</a> for more details).<br>
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>
<br>
Please refer to the <ahref="example-widgets.html">writing custom widgets</a> demo page for more details & an example.
<td>This function applys (refreshes) all currently selected widgets on a table (<spanclass="version updated">v2.16.0</span>; <spanclass="version updated">v2.19.0</span>).
<li><code>callback</code> - optional, a function executed after all widgets have been applied; the only parameter is <code>table</code> (<spanclass="version">v2.19.0</span>).</li>
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>
<br>
This function is called when the <ahref="#applywidgets">applyWidgets</a> method is triggered.
In <spanclass="version updated">v2.19.0</span>, this function was modified to internally use the <ahref="#function-removewidget">removeWidget</a> function & a <ahref="#refreshcomplete"><code>"refreshComplete"</code></a> event is now triggered upon completion.<br>
The <code>doAll</code> flag is set to <code>true</code> if all widgets contained with the global <ahref="#variable-widgets"><code>$.tablesorter.widgets</code></a> array are to be removed.<br>
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>
<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>
<li><code>refreshing</code> - if <code>true</code>, the widget name will not be removed from the <ahref="#widgets"><code>widgets</code></a> option; any other setting and the name will be removed.</li>
<li><code>table</code> - table DOM element (or jQuery object).</li>
<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>
<li><code>key</code> - key to be Object key; this can be a zero-based column index or header class name/id.</li>
As a full example, say you have a header cell with a class name of <code>"event"</code>. And you want to use the <code>textExtraction</code> function for that column, then you would use this function as follows:
The <code>".event"</code> key can be replaced with a zero-based column index, if the <code>textExtraction</code> option is set up using indexes.
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.
<td>This utility function returns the entire column text (raw and parsed) as well as other data (<spanclass="version">v2.21.4</span>; <spanclass="updated version">v2.24.0</span>).
<li><code>rowFilter</code> - can be a jQuery selector, function or element to allow targeting specific rows (e.g. <code>":visible"</code> or <code>":not(.child-row)"</code>); this parameter is used in a jQuery <code><aclass="external"href="http://api.jquery.com/is/">.is()</a></code> function (<spanclass="version">v2.24.0</span>).</li>
<li><code>parsed</code> - parsed text of the current cell.</li>
<li><code>raw</code> - raw (unparsed) text of the current cell.</li>
</ul>
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:
$.tablesorter.getColumnText( table, 3, function( data ) {
if ( data.parsed > 20 ) {
data.$cell.addClass('red');
}
});</pre>
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:
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):
All of these methods of gathering column data might be useful for custom widgets, etc.
<p></p>
<spanclass="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>.
<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).
<li><code>configHeaders</code> - table.config.headers option for the current column.</li>
<li><code>key</code> - get value for this option name, e.g. "sorter".</li>
</ul>
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>
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 <ahref="#usnumberformat"><code>usNumberFormat</code></a> option.<br>
This function uses the <ahref="#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 <ahref="#function-isdigit"><code>$.tablesorter.isDigit</code></a> function.<br>
Any numbers wrapped within parentheses are converted into negative numbers; but any other symbols (e.g. currency) are not removed and will cause this function to determine the string as a non-number (e.g. "$1.25" will be returned as a string).<br>
<li><code>string</code> - a string possibly containing a number.</li>
</ul>
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>
<br>
Use this function as follows:
<preclass="prettyprint lang-js">// boolean value of true returned
<td>Adds the correct <code>data-column</code> indexing to all rows passed to this function (<spanclass="version">v2.16</span>; <spanclass="version updated">v2.25.0</span>).
<p>In <spanclass="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 & footer cells.</p>
<td>This function allows adding/removing a row to the thead, to display any errors (<spanclass="version">v2.15</span>; <spanclass="version updated">v2.23.1</span>).
<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>
<p>In <spanclass="version updated">v2.23.1</span>, a <code>settings</code> parameter was included to make it match the parametered returned by the jQuery <aclass="external"href="http://api.jquery.com/ajaxError/"><code>.ajaxError()</code> method</a>.</p>
<p>In <spanclass="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>
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>"tablesorter-errorRow"</code>; and styled within each theme css file).
<p>When passing this function a message string (in the <code>xhr</code> parameter), there are three possibilities:</p>
<li>HTML row string - <code>'<tr><td colspan="' + table.config.columns + '">yeah, instead of showing your data... I am taking a nap</td></tr>'</code> (the <ahref="#variable-columns"><code>table.config.columns</code> variable</a> contains the number of table columns; use as needed)</li>
<li>undefined - completely leave out a message parameter <code>$.tablesorter.showError( table );</code> to remove all error rows from the table thead.</li>
<li><spanclass="label label-warning">*WARNING*</span> the <code>table</code> parameter no longer accepts multiple tables.</li>
<li>If the <code>xhr</code> parameter is not a string, then the pager <ahref="#pager-ajaxerror"><code>ajaxError</code></a> callback is called to allow modification of the displayed message.</li>
<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>
The external elements (<code>$els</code>) will allow searching the table using "search" and "keyup" events (enter to start & escape to cancel the search), and uses the <ahref="#widget-filter-livesearch"><code>filter_liveSearch</code></a> option, or delayed search.<br>
Include a <code>data-column="#"</code> attribute (where <code>#</code> is the column number) in the search input, to specify to which column the search should apply ~ see <ahref="example-widget-filter-external-inputs.html">this demo</a> for a full example. <spanclass="label label-warning">Warning!</span>, if no <code>data-column</code> attribute is added to the input, the input will be ignored.<br>
In <spanclass="version">v2.15</span>, use a <code>data-column="all"</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 <ahref="#widget-filter-external"><code>filter_external</code></a> option.<br>
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 <ahref="#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 <ahref="example-widget-filter-external-inputs.html">filter external inputs demo</a> for an example.<br>
<br>
<spanclass="label label-warning">Warning!</span> If the third parameter is set to <code>true</code> the saved internal filters (<ahref="#variable-filters"><code>config.$filters</code></a>) will be replaced - not recommended!
<td>This filter widget function allows the updating or replacing of filter select options from an external source. (<spanclass="version">v2.17.5</span>):
<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>
<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>
</ul>
Use this function as follows:<br>
<preclass="prettyprint lang-js">// replace filter select options for the first column with 1,2,3,4
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.
This function respects the parsed data setting for the column, so it uses the <code>filter_useParsedData</code> option, <code>"filter-parsed"</code> class on the header, or the parser <code>parsed</code> flag settinng (<ahref="example-parsers.html">ref</a>).
<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>
<p>Please be aware that this function does not process the array, so the array may contain duplicates and will not be sorted.</p>
The filter <ahref="#function-processoptions"><code>processOptions</code></a> function was added in <spanclass="version">v2.23.4</span> which performs those actions.
<li>To check tablesorter's <code>textSorter</code> option in case there are column specific sorting algorhithms set.</li>
</ul>
See the <ahref="#function-getoptions"><code>getOptions</code></a> function description or the <ahref="#widget-filter-selectsource"><code>filter_selectSource</code></a> option (under "An object containing column keys"; getJSON) for examples which use this function.
<td>This filter widget function allows getting an array of the currently applied filters (<spanclass="version">v2.9</span>; <spanclass="version updated">v2.15</span>)
<li><code>flag</code> - boolean flag (optional; <code>false</code> by default; filter values obtained from the cache), added <spanclass="version">v2.15</span>;</li>
This function returns an array of filter values (e.g. <code>[ '', '', '', '', '', '2?%' ]</code>), or <del><code>false</code></del> an empty array (<spanclass="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="all"</code> containing the value used when matching any table column.<br>
<br>
In <spanclass="version updated">v2.27.0</span>, this function will always return an array.
In <spanclass="version updated">v2.15</span>, this function will also return values from any external filters (set either by the <ahref="#filter-external"><code>filter_external</code> option</a> or using the <ahref="#function-bindsearch"><code>bindSearch</code> function</a>) - with or without an internal filter row.<br>
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>.
<td>This filter widget function allows setting of the filters; include a <code>true</code> boolean to actually apply the search (<spanclass="version">v2.9</span>; <spanclass="version updated">v2.24.3</span>):
<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>
<p>In <spanclass="version updated">v2.24.3</span>, if the <code>apply</code> parameter is left undefined, it will now default to <code>true</code>.</p>
As of <spanclass="version updated">v2.15</span>, this function will also set values in any external filters (set either by the <ahref="#filter-external"><code>filter_external</code> option</a> or using the <ahref="#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="all"</code> using the <code>bindSearch</code> function so your users will know that a search has been applied.<br>
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).
<td>This resizable widget function allows resetting column width changes and clearing out the saved set widths (<spanclass="version">v2.4</span>; <spanclass="version updated">v2.10.1</span>)
<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>
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).
<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 (<spanclass="version">v2.10</span>).
<divclass="collapsible"><br>
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>
<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>
<li><code>options</code> - storage options; see below</li>
</ul>
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:
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:
To change the default data attributes, use the <code>options</code> to modify them as follows:<preclass="prettyprint lang-js">$.tablesorter.storage( table, key, value, {
The <ahref="#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>
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>
<li><aclass="external"href="http://jquery.com/download/">jQuery</a> (1.2.6 or higher; some widgets, demos &<aclass="external"href="http://api.jquery.com/data/#data-html5">HTML5 data-attributes</a> need jQuery 1.4.3+)</li>
<p>First, please review the <aclass="external"href="https://github.com/Mottie/tablesorter/wiki/FAQ">FAQ</a> page to see if it will help you resolve the problem.</p>
<p>If you are having a problem with the plugin or you want to submit a feature request, please <aclass="external"href="https://github.com/Mottie/tablesorter/issues">submit an issue</a>.</p>
<p>Some basic <ahref="../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>
<p>For questions about jQuery, try <aclass="external"href="http://irc.jquery.org/">irc</a>, <aclass="external"href="http://stackoverflow.com/tags/jquery/info">stackoverflow</a>, or the <aclass="external"href="http://forum.jquery.com/">jQuery forums</a>.</p>
Additional & Missing documentation, alphanumeric sort, numerous widgets, unit testing and other changes added by <aclass="external"href="https://github.com/Mottie/tablesorter">Mottie</a>.