diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 729e5ed7..996af125 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -1,6 +1,6 @@ /*! * tablesorter pager plugin - * updated 12/16/2013 (v2.14.5) + * updated 1/21/2014 (v2.15.0) */ /*jshint browser:true, jquery:true, unused:false */ ;(function($) { @@ -64,8 +64,8 @@ // Save pager page & size if the storage script is loaded (requires $.tablesorter.storage in jquery.tablesorter.widgets.js) savePages: true, - //defines custom storage key - storageKey:'tablesorter-pager', + // defines custom storage key + storageKey: 'tablesorter-pager', // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty // table row set to a height to compensate; default is false diff --git a/docs/css/jq.css b/docs/css/jq.css index 533090da..11c3e6b1 100644 --- a/docs/css/jq.css +++ b/docs/css/jq.css @@ -9,19 +9,24 @@ kbd {margin:0px 0.1em; padding:0.1em 0.6em;border-radius: 3px;border: 1px solid .demo h1,.demo h1 a {font-size:120%;text-align:center;text-decoration:none;color:#000;} .demo p,.center {text-align:center;} .demo table.tablesorter {font-size:14px;} +table th {vertical-align:top;} +#config th {text-shadow:none;} table td.info { background: #eee; } table.info {border:#000 1px solid;border-collapse:collapse;margin:10px 0 0 10px;} table.tablesorter table.info tbody th,table.tablesorter table.info td {border:#000 1px solid;} table.tablesorter table.info tbody th {background:#eee;} table.options {width:100%;} table.options pre {width:95%;} -table.options .property {width:115px;} +table.options .property, .setWidth {width:115px;} table.options .type {width:80px; } -table.options .defaults {width:200px;} +table.options .defaults {width:160px;} table.options .examples {width:60px;} table.compatibility { width: 50%; float: right; font-size: .8em; margin-left: 20px; } table.compatibility th,table.compatibility td { text-align: center; padding: 2px; } pre,#display {overflow-x:auto;padding:15px;border:1px solid #ddd;border-left-width:5px;} +pre.lang-js, pre.lang-javascript {border-left-color: #f1bf26;} +pre.lang-html {border-left-color: #ef6328;} +pre.lang-css {border-left-color: #27aae2;} pre,#display {background-color:#eee;font-size:small;list-style:none;} pre.prettyprint {padding:5px;} code {background-color: #e6e6e6; padding: 1px 5px;} @@ -34,7 +39,7 @@ pre.normal {background-color:transparent;border:none;border-left-width:0;overflo #start,#case,.bright {color:#007baa;} #demo strong {color:#a00;} hr {height:1px;} -ul {list-style:square;} +ul {list-style:square;padding-left:20px;} #banner {margin:20px 20px 5px 20px;padding:0;text-align:left;} #banner *,.demo h1,.demo h1 em {color:#232121;font-family:Georgia, Palatino, Times New Roman;font-size:30px;font-style:normal;font-weight:400;margin:0;padding:0;} #banner h1 {display:block;float:left;} @@ -45,17 +50,20 @@ ul {list-style:square;} #banner a {display:block;font-size:14px;margin:5px 0 0;padding:10px 0 0;float:right;} .github-btn {border:0;overflow:hidden;vertical-align: middle;} a.external {background-image:url(../img/external.png);background-position:center right;background-repeat:no-repeat;padding-right:12px;} +a.link {background-image:url(../img/link.png);background-position:center right;background-repeat:no-repeat;padding-right:12px;} form {font-size:10pt;margin-bottom:20px;width:auto;} form fieldset {padding:10px;text-align:left;width:140px;} div#main h1 {border-bottom:1px solid #cdcdcd;display:block;padding:4px 0 2px;} table#tablesorter-demo {margin: 10px 0 0 0;} table, p.small,.smallcode code {font-size:small;} p.small {padding-left: 25px;} +.xsmall {font-size:11px;} p.tip em, div.tip em,.label-info {padding: 2px; background-color: #5bc0de; color: #fff; border-radius: .25em;} .label { padding: 0.1em 0.6em 0.1em; font-size: 75%; color: #fff; border-radius: .25em; } span.tip em, .label-success { background-color: #5cb85c; } span.tip.old em, .label-default { background-color: #999; } -span.warn em { background-color: #ce5300; } +span.warn em, .label.alert { background-color: #d9534f; } +.label.warning { background-color: #f0ad4e; } tr td.lookhere, span.lookhere { background-color: rgba(230,191,153,0.5); } .ui-slider .ui-slider-handle { width: 0.8em; height: 0.8em; } div.digg {float: right;} @@ -66,15 +74,19 @@ div.digg {float: right;} #pager-demo th.remove { width: 20px; } /* pager demo */ #pager-demo button.remove { width: 20px; height: 20px; font-size: 10px; color: #800; } .box { width: 48%; min-width: 300px; float: left; padding: 0 1%; } -td a.alert { color: #a00; padding: 0; } +a.alert { color: #a00; padding: 0; } span.alert { padding: 1px 3px; } .hidden { display: none; } .results { color: red; } .clear { clear: both; } .bootstrap_buttons button { margin: 5px 0 0 0; } -#main .ui-accordion-header a { font-size: 14px; margin-left: 24px; } +#main .ui-accordion-header a { font-size: 14px; } #main .ui-accordion-content { font-size: 14px; } +.accordion { position: relative; } +.accordion .accordion-link { position: absolute; right: 1%; margin-top: 16px; z-index: 1; width: 12px; height: 12px;} .remark, .error { font-weight: bold; color: red; font-size: 18px; } +table th.nobold { font-weight: normal; } +table th a { text-decoration: underline; color: #000; } #group #slider0,#group #slider1,#group #slider2 { width: 100px; height: 3px; font-size: 0.8em; display: inline-block; margin-left: 10px; } #group .demo-label { display: inline-block; min-width: 120px; } @media all and (max-width: 650px) { diff --git a/docs/example-child-rows-filtered.html b/docs/example-child-rows-filtered.html index 10f9e4ac..7a4f42af 100644 --- a/docs/example-child-rows-filtered.html +++ b/docs/example-child-rows-filtered.html @@ -87,6 +87,7 @@
  • Click the link in the Order # column to reveal the hidden child row cells (original demo). This option is available in the original plugin.
  • The filter widget will work with the original tablesorter plugin, just include the jquery.tablesorter.widget.js file and initialize the widget as seen below.
  • Combining the filter widget and pager plugin will not work as expected.
  • +

    Demo

    diff --git a/docs/example-option-digits.html b/docs/example-option-digits.html index 321d52e9..df935a01 100644 --- a/docs/example-option-digits.html +++ b/docs/example-option-digits.html @@ -37,6 +37,8 @@
  • Click on any column header to sort that column.
  • The alphanumeric sort working in the first column was added in version 2.0.6 (not part of the original plugin).
  • The above sort was replaced with a natural sort in version 2.2.
  • +
  • This example demonstrates that common table values are auto-detected (including plain text, currency, percentages, and positive & negative numbers), so there is no need to set a specific parser unless you notice an issue with how a column is sorting.
  • +
  • Issues may arise if a column contains mixed data, e.g. "N/A" is located at the top of a numeric column; in this case the column will be detected as a text column and not a numeric column. If issues occur, add a sorter-digit class name to that header cell.
  • diff --git a/docs/example-option-sort-list.html b/docs/example-option-sort-list.html index 5617865b..d2e2caa1 100644 --- a/docs/example-option-sort-list.html +++ b/docs/example-option-sort-list.html @@ -2,7 +2,7 @@ - jQuery plugin: Tablesorter 2.0 - Set an initial sort order + jQuery plugin: Tablesorter 2.0 - Set an initial table sort @@ -19,12 +19,16 @@ @@ -38,7 +42,65 @@

    Demo

    -
    +

    Set initial sort using the sortList option

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    First NameLast NameAgeTotalDiscountDate
    PeterParker28$9.9920%Jul 6, 2006 8:14 AM
    JohnHood33$19.9925%Dec 10, 2002 5:14 AM
    ClarkKent18$15.8944%Jan 12, 2003 11:14 AM
    BruceAlmighty45$153.1944%Jan 18, 2001 9:12 AM
    BruceEvans22$13.1911%Jan 18, 2007 9:12 AM
    + +

    Set initial sort using a data attribute

    +
    + diff --git a/docs/example-pager-ajax.html b/docs/example-pager-ajax.html index 4b40a63e..7ea3c805 100644 --- a/docs/example-pager-ajax.html +++ b/docs/example-pager-ajax.html @@ -5,13 +5,13 @@ jQuery plugin: Tablesorter 2.0 - Pager plugin - Ajax - + - + - + @@ -26,15 +26,6 @@ - - - - + + diff --git a/docs/example-widget-column-selector.html b/docs/example-widget-column-selector.html index a6ecfd1e..d7897317 100644 --- a/docs/example-widget-column-selector.html +++ b/docs/example-widget-column-selector.html @@ -8,8 +8,8 @@ - - + + @@ -22,15 +22,6 @@ - - +/* Grouping widget css */ +tr.group-header td { + background: #eee; +} +.group-name { + text-transform: uppercase; + font-weight: bold; +} +.group-count { + color: #999; +} +.group-hidden { + display: none !important; +} +.group-header, .group-header td { + user-select: none; + -moz-user-select: none; +} +/* collapsed arrow */ +tr.group-header td i { + display: inline-block; + width: 0; + height: 0; + border-top: 4px solid transparent; + border-bottom: 4px solid #888; + border-right: 4px solid #888; + border-left: 4px solid transparent; + margin-right: 7px; + user-select: none; + -moz-user-select: none; +} +tr.group-header.collapsed td i { + border-top: 5px solid transparent; + border-bottom: 5px solid transparent; + border-left: 5px solid #888; + border-right: 0; + margin-right: 10px; +} @@ -83,15 +81,6 @@ - - - - + + + background: #eee; +} +.group-name { + text-transform: uppercase; + font-weight: bold; +} +.group-count { + color: #999; +} +.group-hidden { + display: none; +} +.group-header, .group-header td { + user-select: none; + -moz-user-select: none; +} +/* collapsed arrow */ +tr.group-header td i { + display: inline-block; + width: 0; + height: 0; + border-top: 4px solid transparent; + border-bottom: 4px solid #888; + border-right: 4px solid #888; + border-left: 4px solid transparent; + margin-right: 7px; + user-select: none; + -moz-user-select: none; +} +tr.group-header.collapsed td i { + border-top: 5px solid transparent; + border-bottom: 5px solid transparent; + border-left: 5px solid #888; + border-right: 0; + margin-right: 10px; +} @@ -62,15 +62,6 @@ - - @@ -90,44 +96,52 @@
    Notes about the addWidget template:
      -
    • The id block is required and must be unique.
    • -
    • The priority block is optional (v2.9): +
    • The id block: +
        +
      • The widget id, or name, must be unique!
      • +
      • The id, or name, can contain special characters and/or spaces.
      • +
      • This setting is required.
      • +
      +
    • +
    • The priority block (added v2.9):
      • Set the widget priority using any number; think of it like setting the css z-index.
      • This tells the plugin the order in which to run the widgets, lowest number priority first.
      • The default widgets have priorities set in intervals of 10 (see the widget priority table), so to run your custom widget before a specific widget, set your widget priority to less than that number.
      • -
      • If no priority is specified, it defaults to 10.
      • +
      • This block is not supported in older versions!
      • +
      • This setting is optional, but if no priority is specified, it defaults to 10.
    • -
    • The options block (v2.8): +
    • The options block (added v2.8):
      • Include any widget options to be automatically be extended with any set widgetOptions (from table.config.widgetOptions).
      • -
      • This block was added in tablesorter v2.8 and is not supported in older versions!
      • As of v2.8, no included widgets will be using this to maintain backwards compatibility with older versions. This changed when v2.9 was released.
      • +
      • This block is not supported in older versions!
      • This block is optional.
    • -
    • The init block: +
    • The init block (added v2.0.28):
        -
      • This code is called only after tablesorter has initialized, but before initial sort and before any of the widgets are applied; it is only run once.
      • -
      • This block was added in v2.0.28 and it not supported in older versions.
      • -
      • Since, v2.0.28, only the saveSort widget uses this block to ensure that the stored sort is applied before .
      • +
      • This code is called only after tablesorter has initialized, but before initial sort and before any of the widgets are applied (via the format block); it is only run once.
      • +
      • Since, v2.0.28, only the saveSort widget uses this block to ensure that the stored sort is applied before; but some of the newer widgets (post v2.9) are using this code block.
      • +
      • This block is not supported in older versions.
      • This block is optional.
    • -
    • The format block: +
    • The format block (modified v2.0.23):
      • This block is part of the original addWidget template and is required.
      • In the original template, only the table parameter is provided. After v2.0.28, config and widgetOptions were provided as additional parameters (sorry the previous docs were incorrect).
      • The initFlag is correctly set in v2.8+.
    • -
    • The remove block: +
    • The remove block (added v2.4):
      • This code is called when either the refreshWidgets or destroy methods are called.
      • The code contained within this block must remove all additional content/elements added by the widget. Also, any rows or content that is hidden must be restored.
      • If additional rows are added to the table, make sure to include the class name within the selectorRemove option.
      • -
      • This block was added in v2.4 and is optional.
      • +
      • This block was added in v2.4, and not supported in older versions.
      • +
      • This block is optional.
    @@ -160,7 +174,7 @@ $.tablesorter.addWidget({ }, format: function(table, config, widgetOptions, initFlag) { // widget code to apply to the table *AFTER EACH SORT* - // the initFlag is true when this format is called from the init + // set the initFlag to true when this format is called from the init // function above otherwise initFlag is undefined // * see the saveSort widget for a full example * }, diff --git a/docs/img/link.png b/docs/img/link.png new file mode 100644 index 00000000..cd5caec6 Binary files /dev/null and b/docs/img/link.png differ diff --git a/docs/index.html b/docs/index.html index 81f893d3..9a9daa3d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -25,10 +25,13 @@ @@ -82,6 +85,7 @@ Widget & Pager Options Methods Events + API Download Compatibility Support @@ -105,7 +109,7 @@ Author: Christian Bach
    Maintainer: Rob Garrison (Mottie)
    Version: 2.1+ (changelog)  - +
    Licence: @@ -124,6 +128,7 @@
  • Widget & Pager Options (v2.1)
  • Methods
  • Events
  • +
  • API
  • Download
  • Compatibility
  • Support
  • @@ -154,7 +159,7 @@

    Demo

    -
    First Name
    +
    @@ -299,7 +304,7 @@

    Start by telling tablesorter to sort your table when the document is loaded:

    -
    $(function(){
    +	
    $(function(){
       $("#myTable").tablesorter();
     });
    @@ -309,7 +314,7 @@ tablesorter to sort on the first and second column in ascending order.

    -
    $(function(){
    +	
    $(function(){
       $("#myTable").tablesorter({ sortList: [[0,0], [1,0]] });
     });
    @@ -328,72 +333,101 @@

    Basic

    Sorting

    Using Parsers / Extracting Content

    -

    Plugins / Custom Widgets / Custom Parsers

    +

    Plugins / Widgets
    + * widgets with an asterisk are in the jquery.tablesorter.widgets.js file (except for extra filter formatter functions)

    -
  • Assorted date parsers (v2.8; v2.14).
  • +

    Custom Parsers

    + + +

    Work-in-progress

    + +
    @@ -484,14 +521,14 @@ TIP! Click on the link in the property column to reveal full details (or toggle|show|hide all) or double click to update the browser location. -
    Account #
    +
    - - + + @@ -536,7 +573,10 @@ - + @@ -651,6 +691,18 @@ + + + + + + + + @@ -705,7 +757,7 @@
    The sorter should be set to "shortDate" and the date format can be set in the "dateFormat" option or set for a specific columns within the "headers" option. See the demo page to see it working. -
    $(function(){
    +						
    $(function(){
       $("table").tablesorter({
     
         dateFormat : "mmddyyyy", // default date format
    @@ -779,31 +831,24 @@
     				
    - - - - - - - - - - - - - - - - @@ -1038,7 +1070,7 @@ From the example function above, you'll end up with something similar to this HT
  • SortAppend is the default sort that is added to the end of the users sort selection (null by default).
  • The value of these sort options is an array of arrays and can include one or more columns. The format is an array of instructions for per-column sorting and direction in the format: [[columnIndex, sortDirection], ... ] where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: [[0,0],[1,0]]. -
    $(function(){
    +				
    $(function(){
       $("table").tablesorter({
         sortForce  : [[0,0]],        // Always sort first column first
         sortList   : [[1,0], [2,0]], // initial sort columns (2nd and 3rd)
    @@ -1108,7 +1140,10 @@ From the example function above, you'll end up with something similar to this HT
     					
     					
     				
    -				
    + @@ -1134,8 +1169,8 @@ From the example function above, you'll end up with something similar to this HT
  • Please see the example page for instrcutions on how to modify the above equivalency table.
  • -
  • If you would like to continuing using the String.localeCompare method, then set the sortLocaleCompare option to false and use the new textSorter option as follows: -
    $('table').tablesorter({
    +						
  • If you would like to continue using the String.localeCompare method, then set the sortLocaleCompare option to false and use the new textSorter option as follows: +
    $('table').tablesorter({
       textSorter: function(a,b) {
         return a.localeCompare(b);
       }
    @@ -1168,7 +1203,7 @@ From the example function above, you'll end up with something similar to this HT
     				
  • - + @@ -1199,7 +1234,7 @@ From the example function above, you'll end up with something similar to this HT - + @@ -1276,18 +1311,18 @@ From the example function above, you'll end up with something similar to this HT

    You can customize the text extraction by writing your own text extraction function "myTextExtraction" which you define like: -
    var myTextExtraction = function(node, table, cellIndex){
    +					
    var myTextExtraction = function(node, table, cellIndex){
       // extract data from markup and return it
       // originally: return node.childNodes[0].childNodes[0].innerHTML;
       return $(node).find('selector').text();
     }
     $(function(){
    -  $("#myTable").tableSorter( { textExtraction: myTextExtraction } );
    +  $("#myTable").tablesorter( { textExtraction: myTextExtraction } );
     });
    tablesorter will pass the current table cell object for you to parse and return. Thanks to Josh Nathanson for the examples. Updated to a jQuery example by Rob G (Mottie).

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

    Added table and cellIndex variables to the textExtraction function in version 2.1.2.

    -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         textExtraction: {
           1: function(node, table, cellIndex) {
    @@ -1312,7 +1347,7 @@ $(function(){
     					

    Here is an example: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         numberSorter : function(a, b, direction, maxColumnValue){
           // direction; true = ascending; false = descending
    @@ -1335,13 +1370,13 @@ $(function(){
     					

    Include a script like naturalSort.js as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         textSorter : naturalSort
       });
     });
    or use the localeCompare sort -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         // replace the OVERALL text sorter function
         textSorter: function(a, b, direction, columnIndex, table){
    @@ -1352,7 +1387,7 @@ $(function(){
         }
       });
     });
    In v2.12, the textSorter option will now accept a text sorter per column: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         textSorter : {
           // replace INDIVIDUAL COLUMN text sorter functions
    @@ -1372,7 +1407,10 @@ $(function(){
     
     					
    -
    + @@ -1435,7 +1473,7 @@ $(function(){ Previously documented widget options widgetZebra, widgetColumns and widgetUitheme will be retained for backwards compatibility.

    Use the widgetOptions option as follows, please note that each option is followed by a comma (except the last one): -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
     
         // initialize a bunch of widgets
    @@ -1452,8 +1490,8 @@ $(function(){
           columns_tfoot : true,
     
           // *** filter widget ***
    -      // show any column matches
    -      filter_anyMatch      : false,
    +      // jQuery selector string (or jQuery object) of external anyMatch filter
    +      // filter_anyMatch   : null, // THIS OPTION WAS REMOVED IN V2.15
           // Include child rows content in the search
           filter_childRows     : false,
           // show column filters
    @@ -1462,6 +1500,8 @@ $(function(){
           filter_cssFilter     : '',
           // data attribute in the header cell that contains the default filter value
           filter_defaultAttrib : 'data-value',
    +      // jQuery selector string (or jQuery object) of external search inputs
    +      filter_external      : '',
           // class added to filtered rows; needed by pager plugin
           filter_filteredRow   : 'filtered',
           // add custom filter elements to the filter row
    @@ -1562,7 +1602,7 @@ $(function(){
     				
    - + @@ -2959,7 +3008,7 @@ $.extend($.tablesorter.themes.jui, { - + @@ -2967,15 +3016,15 @@ $.extend($.tablesorter.themes.jui, { - + - - + + @@ -3031,7 +3080,7 @@ $.extend($.tablesorter.themes.jui, { - + @@ -3039,7 +3088,7 @@ $.extend($.tablesorter.themes.jui, { - + @@ -3047,7 +3096,7 @@ $.extend($.tablesorter.themes.jui, { - + @@ -3055,7 +3104,7 @@ $.extend($.tablesorter.themes.jui, { - + @@ -3063,10 +3112,10 @@ $.extend($.tablesorter.themes.jui, { - @@ -3089,7 +3138,7 @@ $.extend($.tablesorter.themes.jui, { - + @@ -3127,6 +3176,43 @@ $.extend($.tablesorter.themes.jui, { + + + + + + + + + @@ -3179,12 +3265,12 @@ $.extend($.tablesorter.themes.jui, { TIP! Click on the link in the method column to reveal full details (or toggle|show|hide all) or double click to update the browser location. -
    Property Type DefaultDescriptionLinkDescriptionLink
    String "tablesorter-childRow" Add this css class to a child row that should always be attached to its parent. Click on the "cssChildRow" link to toggle the view on the attached child row. Previous default was "expand-child" (Changed in v2.4).Ex:1 2 + 1 + 2 +
    String""Additional CSS class applied to style the header when no sort is applied (v2.15). +

    + A "tablesorter-headerUnSorted" class will always be added to an unsorted header cell; this option contains any additional class names to add. Currently, no themes use this class name. +
    +
    StringExample
    headerListArray[ ] (empty array)Internal list of each header element as selected using jQuery selectors in the selectorHeaders option. Not really useful for normal usage.
    Object null - An object of instructions for per-column controls in the format: headers: { 0: { option: setting }, ... } + An object of instructions for per-"header cell" controls in the format: headers: { 0: { option: setting }, ... } + docs updated

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

    The plugin attempts to detect the type of data that is contained in a column, but if it can't figure it out then it defaults to alphanumeric. You can easily override this by setting the header argument (or column parser). See the full list of default parsers here or write your own. -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         headers: {
     
    -      // See example - Disable first column
    +      // See example - Disable first header cell
           0: { sorter: false },
     
           // See example 2: Sort column numerically & treat any text as if its value is:
    @@ -818,7 +863,7 @@
           // this option will not work if added as metadata
           5: { lockedOrder: "asc" },
     
    -      // See Example 4: Initial sort order direction of seventh column
    +      // See Example 4: Initial sort order direction of seventh header cell
           6: { sortInitialOrder: "desc" },
     
           // Set filter widget options for this column
    @@ -827,14 +872,32 @@
           8: { filter: "parsed" }, // use parsed data for this column in the filter search
     
           // Set resizable widget options for this column
    -      9: { resizable: false } // prevent resizing of column 9
    +      9: { resizable: false } // prevent resizing of header cell 9
     
         }
       });
    -});
    +}); + Please note that the headers index values corresponds to the table header cells index (zero-based) and not the actual columns. For example, given the following table thead markup, the header-index counts the header th cells and does not actually match the data-column index when extra rows and/or colspan or rowspan are included in any of the header cells: +
    <thead>
    +	<tr>
    +		<th colspan="4" data-column="0">header-index 0</th>
    +	</tr>
    +	<tr>
    +		<th data-column="0">header-index 1</th>
    +		<th data-column="1">header-index 2</th>
    +		<th data-column="2">header-index 3</th>
    +		<th data-column="3">header-index 4</th>
    +	</tr>
    +	<tr>
    +		<th colspan="2" data-column="0">header-index 5</th>
    +		<th colspan="2" data-column="2">header-index 6</th>
    +	</tr>
    +</thead>
    + So, in the above example, to disable the sort of the second table column (data-column index of 1), the header cell of index 2 needs to be set as follows: 2 : { sorter : false }. +
    - Ex:1 + 1 2 3 4 @@ -892,7 +955,7 @@

    In versions 2.0.6+, all TH text is wrapped in a div with a class name of "tablesorter-inner" by default. In the example below, the header cell (TH) div is given a class name (source). -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         headerTemplate: '{content}',
         onRenderHeader: function (){
    @@ -920,7 +983,7 @@
     					

    The onRenderTemplate function receives a column index and template string parameters. The template string, from the headerTemplate option, will already have the {icon} and {content} tags replaced; it's just a string of formatted HTML. When done manipulating this string, return it. Here is an example: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         headerTemplate: '{icon}{content}',
         onRenderTemplate: function (index, template){
    @@ -941,37 +1004,6 @@ From the example function above, you'll end up with something similar to this HT
     				
    Example
    Object{ }Internal list of all of the parsers. Here is a complete list of default parsers: -
    -
    - - - - - - - - - - - - - -
    sorter: falsedisable sort for this column.
    sorter: "text"Sort alpha-numerically.
    sorter: "digit"Sort numerically.
    sorter: "currency"Sort by currency value (supports "£$€¤¥¢").
    sorter: "ipAddress"Sort by IP Address.
    sorter: "url"Sort by url.
    sorter: "isoDate"Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD; these formats can be followed by a time).
    sorter: "percent"Sort by percent.
    sorter: "usLongDate"Sort by date (U.S. Standard, e.g. Jan 18, 2001 9:12 AM or 18 Jan 2001 9:12 AM (new in v2.7.4)).
    sorter: "shortDate"Sort by a shortened date (see dateFormat; these formats can also be followed by a time).
    sorter: "time"Sort by time (23:59 or 12:59 pm).
    sorter: "metadata"Sort by the sorter value in the metadata - requires the metadata plugin.

    - Check out the headers option to see how to use these parsers in your table (example #1).
    Or add a header class name using "sorter-" plus the parser name (example #2), this includes custom parsers (example #3). -
    -
    - Ex:1 - 2 - 3 -
    String Ex:1 2 + 1 + 2 +
    sortResetKey String "ctrlKey"The key used to reset sorting on the entire table. Defaults to the control key. The other options are "shiftKey" or "altKey". Reference: https://developer.mozilla.org/en/DOM/MouseEventThe key used to reset sorting on the entire table. Defaults to the control key. The other options are "shiftKey" or "altKey" (reference).
    sortMultiSortKey String "shiftKey"The key used to select more than one column for multi-column sorting. Defaults to the Shift key. The other options are "ctrlKey" or "altKey". Reference: https://developer.mozilla.org/en/DOM/MouseEventThe key used to select more than one column for multi-column sorting. Defaults to the Shift key. The other options are "ctrlKey" or "altKey" (reference). Example
    Ex:1 2 + 1 + 2 +
    String Undefined - This option was added to set a specific page when storing data using the $.tablesorter.storage code. v2.12. + This option was added to set a specific page when storing data using the $.tablesorter.storage code. v2.12.

    More specifically, when the storage function is used, it attempts to give every table a unique identifier using both the page url and table ID (or index on the page if no id exists). This option allows you to override the current page url (it doesn't need to be a url, just some constant value) and save data for multiple tables across a domain.

    @@ -1593,7 +1633,7 @@ $(function(){
    When the column styling widget is initialized, it automatically applied the default class names of "primary" for the primary sort, "secondary" for the next sort, "tertiary" for the next sort, and so on (add more as needed)... (v2.0.17). Use the widgetColumns option to change the css class name as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["columns"], // initialize column styling of the table
         widgetColumns: { css: ["primary", "secondary", "tertiary" ] }
    @@ -1616,7 +1656,7 @@ $(function(){
     					Find more jQuery UI class names by hovering over the Framework icons on this page: http://jqueryui.com/themeroller/

    Use the widgetUitheme option to change the css class name as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["uitheme"], // initialize ui theme styling widget of the table
         widgetUitheme: {
    @@ -1643,7 +1683,7 @@ $(function(){
     					
    When the zebra striping widget is initialized, it automatically applied the default class names of "even" and "odd". Use the widgetZebra option to change the css class name as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["zebra"], // initialize zebra striping of the table
         widgetZebra: { css: [ "normal-row", "alt-row" ] }
    @@ -1659,7 +1699,7 @@ $(function(){
     	
     	

    Widget & Pager Options

    - +
    @@ -1682,21 +1722,21 @@ $(function(){
  • The applied order of widget is dependent of the widget priority, from low to high.
  • Widget priority values do not need to be unique. Any new widget without a defined priority will automatically have a priority of 10.
  • The pager, being a plugin, is actually initialized after tablesorter has initialized and all selected widgets applied.
  • -
  • * The saveSort and resizable widgets use the $.tablesorter.storage function by default and thus need the parseJSON function which is available in jQuery 1.4.1+.
  • +
  • * The saveSort and resizable widgets use the $.tablesorter.storage function by default and thus need the parseJSON function which is available in jQuery 1.4.1+.

  • TIP! Click on the link in the property column to reveal full details (or toggle|show|hide all) or double click to update the browser location. -
    Widget PriorityNameRequires jQueryLimiting function
    +
    - - + + @@ -1719,7 +1759,7 @@ $(function(){

    Use the "columns" option to change the css class name as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["columns"], // initialize column styling of the table
         widgetOptions : {
    @@ -1736,11 +1776,11 @@ $(function(){
     				
    - - - - - - - - @@ -1815,7 +1823,7 @@ $(function(){

    Use the filter_childRows option include child row text as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -1836,7 +1844,7 @@ $(function(){
     					

    Use the filter_columnFilters option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -1852,13 +1860,13 @@ $(function(){
     				
    - + + + + + + + + @@ -1901,7 +1942,7 @@ $(function(){
    • To add the jQuery UI slider, follow this example: -
      $(function(){
      +					
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions : {
      @@ -1929,7 +1970,10 @@ $(function(){
       					
    - + @@ -1944,7 +1988,7 @@ $(function(){
    • Make a sorted select dropdown list of all column contents. Repeated content will be combined. -
      $(function(){
      +							
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions: {
      @@ -1962,7 +2006,7 @@ $(function(){
       							Make a select dropdown list with custom option settings. Each option must have a corresponding function which returns a boolean value; return true if there is a match, or false with no match.
       
       							

      Regex example

      -
      $(function(){
      +							
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions: {
      @@ -1987,7 +2031,7 @@ $(function(){
         });
       });

      Comparison example

      -
      $(function(){
      +							
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions: {
      @@ -2013,7 +2057,7 @@ $(function(){
       						
    • Make a custom filter for the column. -
      $(function(){
      +							
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions: {
      @@ -2048,7 +2092,7 @@ $(function(){
       					

      Use the filter_hideFilters option as follows: -
      $(function(){
      +					
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions : {
      @@ -2069,7 +2113,7 @@ $(function(){
       					

      Use the filter_ignorecase option as follows: -
      $(function(){
      +					
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions : {
      @@ -2124,7 +2168,7 @@ $(function(){
       					To use this option, point to a reset button or link using a jQuery selector. For example, add this button (<button class="reset">Reset</button>) to the table header, or anywhere else on the page. That element will be used as a reset for all column and quick search filters (clears all fields):
       					

      Use the filter_reset option as follows: -
      $(function(){
      +					
      $(function(){
         $("table").tablesorter({
           widgets: ["filter"],
           widgetOptions : {
      @@ -2141,7 +2185,7 @@ $(function(){
       				
    @@ -2196,7 +2240,7 @@ $('table').trigger('search', false);

    Use the filter_serversideFiltering option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -2217,7 +2261,7 @@ $('table').trigger('search', false);

    Use the filter_startsWith option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -2238,7 +2282,7 @@ $('table').trigger('search', false);

    Use the filter_useParsedData option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -2271,7 +2315,7 @@ $('table').trigger('search', false);

    Use the filter_defaultAttrib option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -2292,7 +2336,7 @@ $('table').trigger('search', false);
    Changed to empty string in v2.11, as the "tablesorter-stickyHeader" class will always be added to the sticky header row; this option now contains any additional class names to add.

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

    Use the "stickyHeaders" option to add an extra css class name as follows: -

    $(function(){
    +						
    $(function(){
       $("table").tablesorter({
         widgets: ["stickyHeaders"],
         widgetOptions : {
    @@ -2316,7 +2360,7 @@ $('table').trigger('search', false);
    So if your table ID is "gummy", then the cloned sticky table id becomes "gummy-sticky"

    Use the "stickyHeaders_cloneId" option to change the cloned table id as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["stickyHeaders"],
         widgetOptions : {
    @@ -2338,7 +2382,7 @@ $('table').trigger('search', false);

    Use the stickyHeaders_includeCaption option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["stickyHeaders"],
         widgetOptions : {
    @@ -2360,7 +2404,7 @@ $('table').trigger('search', false);

    Use the stickyHeaders_attachTo option as follows:
    -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["stickyHeaders"],
         widgetOptions : {
    @@ -2382,7 +2426,7 @@ $('table').trigger('search', false);

    If the page includes a fixed navigation bar at the top, like Bootstrap, set "stickyHeaders_offset" option to offset the sticky table header to be below the fixed navigation by setting this option using any of the following examples:
    -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["stickyHeaders"],
         widgetOptions : {
    @@ -2391,8 +2435,8 @@ $('table').trigger('search', false);
    } }); });
    or -
    stickyHeaders_offset : '.navbar-fixed-top' // jQuery selector string
    or -
    stickyHeaders_offset : $('.navbar-fixed-top') // jQuery object
    +
    stickyHeaders_offset : '.navbar-fixed-top' // jQuery selector string
    or +
    stickyHeaders_offset : $('.navbar-fixed-top') // jQuery object
    @@ -2409,7 +2453,7 @@ $('table').trigger('search', false); When this option is false, sticky table headers are unable to detect and match the width of the original table headers when content is added or removed.

    Use the "stickyHeaders_addResizeEvent" option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["resizable"],
         widgetOptions : {
    @@ -2432,7 +2476,7 @@ $('table').trigger('search', false);

    Use the stickyHeaders_zIndex option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["stickyHeaders"],
         widgetOptions : {
    @@ -2454,7 +2498,7 @@ $('table').trigger('search', false);

    Use the "resizable" option to not save the resized widths: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["resizable"],
         widgetOptions : {
    @@ -2478,7 +2522,7 @@ $('table').trigger('search', false);
    If an anchor was included and the table is full width, the column would resize in the opposite direction which my not be intuitive to the user. So set this option as desired, but please be mindful of the user experience.

    Use the "resizable_addLastColumn" option to include the last column resizer as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["resizable"],
         widgetOptions : {
    @@ -2500,7 +2544,7 @@ $('table').trigger('search', false);

    Use the "saveSort" option to not save the current sort: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["saveSort"],
         widgetOptions : {
    @@ -2518,10 +2562,10 @@ $('table').trigger('search', false);
    Property Type DefaultDescriptionLinkDescriptionLink
    Boolean true - Columns widget: If true, the class names from the columns option will also be added to the table thead (v2.4). + Columns widget: If true, the class names from the columns option will also be added to the table thead (v2.4).

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

    Use the "columns_tfoot" option to add the column class names to the tfoot as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["columns"], // initialize column styling of the table
         widgetOptions : {
    @@ -1773,38 +1813,6 @@ $(function(){
     				
    Example
    Booleanfalse - Filter widget: Show any rows that match a search query. If this option is true any column match will show that row; but there are limitations (v2.13.3). -
    -
    - It is best if this filter_anyMatch option is used with a single search input as follows: -
    <input class="search" type="search">
    -<button type="button" class="reset">Reset Search</button>
    -
    $(function(){
    -  $("table").tablesorter({
    -    widgets: ["filter"],
    -    widgetOptions : {
    -      filter_anyMatch : true,
    -      filter_columnFilters: false,
    -      filter_reset: '.reset'
    -    }
    -  });
    -
    -  // Target the $('.search') input using built in functioning
    -  // this binds to the search using "search" and "keyup"
    -  // Allows using filter_liveSearch or delayed search &
    -  // pressing escape to cancel the search
    -  $.tablesorter.filter.bindSearch( $table, $('.search') );
    -
    -});
    -
    Example
    Boolean String or Array ""Additional CSS class applied to each filter - v2.14.6 + Additional CSS class applied to each filter - v2.15

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

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

    Use the "tablesorter-filter" option to add an extra css class name as follows:

    -
    $(function(){
    +						
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -1873,12 +1881,45 @@ $(function(){
     				
    Example
    String"" + Filter widget: jQuery selector string of inputs, outside of the table, to be used for searching table content (v2.15). +
    +
    + Set this option to be a jQuery selector string, or jQuery object, pointing to any external inputs that are to be used for searching the table.
    +
    + Use the filter_external option as follows: +
    $(function(){
    +  $("table").tablesorter({
    +    widgets: ["filter"],
    +    widgetOptions : {
    +      filter_external : '.search'
    +    }
    +  });
    +});
    + These external inputs have one requirement, they must have a data-column="#", where the # targets the column (zero-based index), pointing to a specific column to search.
    +
    <input class="search" type="search" data-column="0" placeholder="Search first column">
    +
    + If you want to search all columns, using the updated "any match" method, set the data column value to "all":
    +
    <input class="search" type="search" data-column="any" placeholder="Search entire table">
    +
    + The updated any matching code will now automatically update all associated inputs with the latest search. +
    + This option replaces filter_anyMatch. +
    +
    Example
    filter_filteredRow String "filtered" - Filter widget: This is the class name applied to all rows that match the filter; used by pager plugin (v2.10). + Filter widget: This is the class name applied to all rows that do not match the filter (hidden rows); used by pager plugin (v2.10).
    Ex: 1 2 + 1 + 2 +
    Boolean false - Filter widget: If the storage utility is available (included with jquery.tablesorter.widgets.js, the last applied filter is saved to storage (v2.14). + Filter widget: If the storage utility is available (included with jquery.tablesorter.widgets.js file, the last applied filter is saved to storage (v2.14).

    Filters saved to local storage (or cookies) will over-ride any default filters within the header data-attribute (set by the filter_defaultAttrib option and be available to the pager before any ajax calls are made.
    @@ -2162,7 +2206,7 @@ $(function(){

    Use the filter_searchDelay option as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["filter"],
         widgetOptions : {
    @@ -2173,7 +2217,7 @@ $(function(){
     
     					If you want to want to initialize the filter without user input, target any one of the filters and trigger a "search".
     
    -					
    // target the first filter input
    +					
    // target the first filter input
     // this method will begin the search after the searchDelay time
     $('input.tablesorter-filter:eq(0)').trigger('search');
     
    @@ -2181,7 +2225,7 @@ $('input.tablesorter-filter:eq(0)').trigger('search');
     $('input.tablesorter-filter:eq(0)').trigger('search', false);
    In tablesorter v2.4+, the trigger can be applied directly to the table: -
    // refresh the widget filter; no delay
    +					
    // refresh the widget filter; no delay
     $('table').trigger('search', false);
    String "jui" - This option contains the name of the theme. Currently jQuery UI ("jui") and Bootstrap ("bootstrap") themes are supported. To modify the class names used, extend from the theme (updated v2.4) + This option contains the name of the theme. Currently jQuery UI ("jui") and Bootstrap ("bootstrap") themes are supported (updated v2.4)
    -

    -
    // Extend the themes to change any of the default class names ** NEW **
    +					

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

    +
    // Extend the themes to change any of the default class names ** NEW **
     $.extend($.tablesorter.themes.jui, {
       // change default jQuery uitheme icons - find the full list of icons
       // here: http://jqueryui.com/themeroller/ (hover over them for their name)
    @@ -2549,7 +2593,7 @@ $.extend($.tablesorter.themes.jui, {
     					As before the jQuery UI theme applies the default class names of "ui-icon-arrowthick-2-n-s" for the unsorted column, "ui-icon-arrowthick-1-s" for the descending sort and "ui-icon-arrowthick-1-n" for the ascending sort. (Modified v2.1; Updated in v2.4). Find more jQuery UI class names by hovering over the Framework icons on this page: http://jqueryui.com/themeroller/

    Use the "uitheme" option to change the css class name as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         theme     : 'jui',       // set theme name from $.tablesorter.themes here
         widgets   : ["uitheme"], // initialize ui theme styling widget of the table
    @@ -2560,7 +2604,7 @@ $.extend($.tablesorter.themes.jui, {
     });
    To add a new theme, define it as follows; replace "custom" with the name of your theme: -
    $.tablesorter.themes.custom = {
    +					
    $.tablesorter.themes.custom = {
       table      : 'table',       // table classes
       header     : 'header',      // header classes
       footerRow  : '',
    @@ -2588,7 +2632,7 @@ $.extend($.tablesorter.themes.jui, {
     					

    Use the "zebra" option to change the theme as follows: -
    $(function(){
    +					
    $(function(){
       $("table").tablesorter({
         widgets: ["zebra"], // initialize zebra striping of the table
         widgetOptions: {
    @@ -2632,7 +2676,7 @@ $.extend($.tablesorter.themes.jui, {
         </select>
         <select class="gotoPage" title="Select page number"></select>
       </form>
    -</div>
    Add this option as follows:
    $(function(){
    +</div>
    Add this option as follows:
    $(function(){
       $("table")
         .tablesorter()
         .tablesorterPager({
    @@ -2653,7 +2697,7 @@ $.extend($.tablesorter.themes.jui, {
     					

    Here is an example of how to include the option, it should always be paired with an ajaxProcessing function: -
    $(function(){
    +					
    $(function(){
       $("table")
         .tablesorter()
         .tablesorterPager({
    @@ -2700,7 +2744,7 @@ $.extend($.tablesorter.themes.jui, {
     					

    The customAjaxUrl function has two parameters, the table DOM element and the processed url string (all tags within the ajaxUrl have been replaced with their appropriate values). -
    $(function(){
    +					
    $(function(){
       $("table")
         .tablesorter()
         .tablesorterPager({
    @@ -2733,7 +2777,7 @@ $.extend($.tablesorter.themes.jui, {
     					The ajaxObject is completely customizable, except for the `url` setting which is processed using the pager's `ajaxUrl` and `customAjaxUrl` options.

    See all possible settings in the jQuery.ajax documentation -
    $(function(){
    +					
    $(function(){
       $("table")
         .tablesorter()
         .tablesorterPager({
    @@ -2774,7 +2818,7 @@ $.extend($.tablesorter.themes.jui, {
     					In v2.10, the returned rows is now optional. And it can either be an array of arrays or a jQuery object (not attached to the table)
     					
    Process your ajax data so that the following information is returned: -
    // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
    +					
    // [ total_rows (number), rows (array of arrays), headers (array; optional) ]
     // or [ rows, total_rows, headers ]
     // or [ total_rows, $(rows) ]
     // or [ total_rows ]
    @@ -2789,7 +2833,7 @@ $.extend($.tablesorter.themes.jui, {
       [ "header1", "header2", ... "headerN" ] // optional
     ]
    Note: In v2.14.3, the contents of the array can also contain table cell markup (i.e. "<td class='green'>+ 10%</td>").

    Here is some example JSON (comments added, but not allowed in JSON) which is contained in the City0.json file: -
    {
    +
    {
       // total rows
       "total_rows": 80,
       // headers
    @@ -2807,7 +2851,7 @@ $.extend($.tablesorter.themes.jui, {
         // row 2, etc...
       }]
     }
    The above JSON is processed by the following code (this returns an array of array of table rows): -
    $(function(){
    +
    $(function(){
       $("table")
         .tablesorter()
         .tablesorterPager({
    @@ -2840,7 +2884,7 @@ $.extend($.tablesorter.themes.jui, {
           }
         });
     });
    Or, in tablesorter v2.10, return a jQuery object -
    ajaxProcessing: function(data, table){
    +
    ajaxProcessing: function(data, table){
       if (data && data.hasOwnProperty('rows')) {
         var r, row, c, d = data.rows,
         // total number of rows (required)
    @@ -2868,7 +2912,7 @@ $.extend($.tablesorter.themes.jui, {
         return [ total, $(rows), headers ];
       }
     }
    Or, also in tablesorter v2.10, just build the table yourself and return the total number of rows: -
    ajaxProcessing: function(data, table){
    +
    ajaxProcessing: function(data, table){
       if (data && data.hasOwnProperty('rows')) {
         var r, row, c, d = data.rows,
         // total number of rows (required)
    @@ -2908,7 +2952,7 @@ $.extend($.tablesorter.themes.jui, {
     					This option replaced the original separator option, which only separated the page number from the total number of pages. The formatted output from this option is placed inside the information block targeted by the cssPageDisplay option.

    Use it as follows: -
    $(function(){
    +					
    $(function(){
       $("table")
         .tablesorter()
         .tablesorterPager({
    @@ -2931,7 +2975,12 @@ $.extend($.tablesorter.themes.jui, {
     	
     
    Ex: 1 2 3 4 + 1 + 2 + 3 + 4 +
    size Numeric 10Set initial number of visible rows. This value is changed by the dropdown selector targeted by the cssPageSize option.Set initial number of visible rows. This value is changed by the dropdown selector targeted by the cssPageSize option. Example
    savePages Boolean trueSaves the current pager page size and number. This option requires the $.tablesorter.storage script in the jquery.tablesorter.widgets.js file (v2.11).Saves the current pager page size and number. This option requires the $.tablesorter.storage script in the jquery.tablesorter.widgets.js file (v2.11). Example
    storageKey Stringtablesorter-pagerSaves tablesorter paging to custom key if defined. Useful if you have multiple tables defined."tablesorter-pager"Saves tablesorter paging to custom key if defined. Key parameter name used by the $.tablesorter.storage function. Useful if you have multiple tables defined (v2.15) Example
    cssFirst String ".first"This option contains a jQuery selector string pointing to the go to first page arrow. See container for full HTML.This option contains a jQuery selector string pointing to the go to first page arrow. See container for full HTML. Example
    cssPrev String ".prev"This option contains a jQuery selector string pointing to the go to previous page arrow. See container for full HTML.This option contains a jQuery selector string pointing to the go to previous page arrow. See container for full HTML. Example
    cssNext String ".next"This option contains a jQuery selector string pointing to the go to next page arrow. See container for full HTML.This option contains a jQuery selector string pointing to the go to next page arrow. See container for full HTML. Example
    cssLast String ".last"This option contains a jQuery selector string pointing to the go to last page arrow. See container for full HTML.This option contains a jQuery selector string pointing to the go to last page arrow. See container for full HTML. Example
    String ".gotoPage"This option contains a jQuery selector string pointing to the page select dropdown. See container for full HTML (v2.4) + This option contains a jQuery selector string pointing to the page select dropdown. See container for full HTML (v2.4)

    - Please note that this select dropdown is initially empty and automatically updated by the plugin with the correct number of pages, which depends on the size setting. + Please note that this select dropdown is initially empty and automatically updated by the plugin with the correct number of pages, which depends on the size setting.
    ExamplecssPageSize String ".pagesize"This option contains a jQuery selector string pointing to the page size selector. See container for full HTML.This option contains a jQuery selector string pointing to the page size selector. See container for full HTML. Example
    Booleanfalse + Filter widget: This option was removed in v2.15... sorry for the sudden notice. +
    +
    + This option has been replaced by the filter_external option.
    +
    + Show any rows that match a search query. If this option is true any column match will show that row; but there are limitations (v2.13.3).
    +
    + It is best if this filter_anyMatch option is used with a single search input as follows: +
    <input class="search" type="search">
    +<button type="button" class="reset">Reset Search</button>
    +
    $(function(){
    +  $("table").tablesorter({
    +    widgets: ["filter"],
    +    widgetOptions : {
    +      filter_anyMatch : true,
    +      filter_columnFilters: false,
    +      filter_reset: '.reset'
    +    }
    +  });
    +
    +  // Target the $('.search') input using built in functioning
    +  // this binds to the search using "search" and "keyup"
    +  // Allows using filter_liveSearch or delayed search &
    +  // pressing escape to cancel the search
    +  $.tablesorter.filter.bindSearch( $table, $('.search') );
    +
    +});
    +
    Numeric
    +
    - - + + @@ -3195,7 +3281,7 @@ $.extend($.tablesorter.themes.jui, {
    It does not work the same as "update" in that it only adds rows, it does not remove them.
    Also, use this method to add table rows while using the pager plugin. If the "update" method is used, only the visible table rows continue to exist. -
    // Add multiple rows to the table
    +						
    // Add multiple rows to the table
       var row = '<tr><td>Inigo</td><td>Montoya</td><td>34</td>' +
         '<td>$19.99</td><td>15%</td><td>Sep 25, 1987 12:00PM</td></tr>',
         $row = $(row),
    @@ -3217,7 +3303,7 @@ $.extend($.tablesorter.themes.jui, {
     				
    @@ -3228,7 +3314,7 @@ $('table').find('th:eq(2)').trigger('sort');Using this method will maintai - - + @@ -3286,7 +3372,7 @@ $("table") - - - - - - - - - - - - - - - - - - - @@ -3559,7 +3596,7 @@ $.tablesorter.addHeaderResizeEvent( table, true ); @@ -3570,12 +3607,12 @@ $.tablesorter.addHeaderResizeEvent( table, true ); @@ -3589,7 +3626,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    The disabled state will reveal all table rows and disable, but not hide, pager controls.
    -
    $(function(){
    +						
    $(function(){
       $('table').trigger('disable.pager');
     });
    @@ -3600,14 +3637,13 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    -
    MethodDescriptionLinkDescriptionLink
    Use this method to initialize a sort while targeting a specific column header (v2.9).
    -
    // Target a specific header
    +						
    // Target a specific header
     $('table').find('th:eq(2)').trigger('sort');
    Using this method will maintain the sorting order; so, if the column is already sorted in ascending order, this method will act as if you manually clicked on the header. Whatever sort order is applied is dependent on other option settings such as initialSortOrder, lockedOrder (set within the headers), sortReset option, sortRestart and will be ignored if the column sort is disabled (sorter: false).
    Use this method to sort an initialized table in the desired order.
    -
    // Choose a new sort order
    +						
    // Choose a new sort order
     var sort = [[0,0],[2,0]],
         callback = function(table){
             alert('new sort applied to ' + table.id);
    @@ -3245,17 +3331,17 @@ $("table").trigger("sorton", [sort, callback]);
    Use this method to reset the table to it's initial unsorted state (v2.4.7).
    Don't confuse this method with the sortReset option. This method immediately resets the entire table sort, while the option only resets the column sort after a third click. -
    // Reset the table (make it unsorted)
    +						
    // Reset the table (make it unsorted)
     $("table").trigger("sortReset");
    Example
    / Update the tbody's stored data (update & updateRow do exactly the same thing) + / Update the tbody's stored data (update & updateRows do exactly the same thing)

    -
    // Add new content
    +						
    // Add new content
     $("table tbody").append(html);
     
     // let the plugin know that we made a update
    @@ -3276,7 +3362,7 @@ var sorting = [[2,1],[0,0]];
     $("table")
     	.trigger("update", [ false ])
     	.trigger("sorton", [sorting]);
    - Note: updateRow was added to work around the issue of using jQuery with the Prototype library. Triggering an "update" would make Prototype clear the tbody; Please see issue #217 for more details. + Note: updateRows was added to work around the issue of using jQuery with the Prototype library. Triggering an "update" would make Prototype clear the tbody; Please see issue #217 for more details.
    Example Update a column of cells (thead and tbody) (v2.8).
    -
    // Change thead & tbody column of cells
    +						
    // Change thead & tbody column of cells
     // remember, "eq()" is zero based & "nth-child()" is 1 based
     $("table thead th:eq(2)").html("Number");
     // add some random numbers to the table cell
    @@ -3313,7 +3399,7 @@ $("table").trigger("updateAll", [ resort, callback ]);
    Use this method when more than just one cell like in the "updateCell" method, but you may possibly have to trigger two events: both "update" and "appendCache".

    Note: This is the only method the pager widget uses - the entire table is stored in the cache, but only the visible portion is actually exists in the table. -
    // Table data was just dynamically changed (more than one cell)
    +						
    // Table data was just dynamically changed (more than one cell)
     $("table")
       .trigger("update")
       .trigger("appendCache");
    @@ -3325,7 +3411,7 @@ $("table")
    Update a table cell in the tablesorter data.
    -
    $(function() {
    +						
    $(function() {
       $("table").tablesorter();
     
       $("td.discount").click(function(){
    @@ -3367,7 +3453,7 @@ $("table")
     				
    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.
    -
    $(function(){
    +						
    $(function(){
       // initialize tablesorter without the widget
       $("table").tablesorter();
     
    @@ -3386,7 +3472,7 @@ $("table")
     				
    Apply the set widgets to the table. This method can be used after a table has been initialized, but it won't work unless you update the configuration settings. See the example, it's easier than describing it.
    -
    // Update the list of widgets to apply to the table (add or remove)
    +						
    // Update the list of widgets to apply to the table (add or remove)
     // $("table").data("tablesorter").widgets = ["zebra"]; // works the same as
     $("table")[0].config.widgets = ["zebra"];
     
    @@ -3401,7 +3487,7 @@ $('table').trigger('applyWidgets');
     				
    Use this method to remove tablesorter from the table.
    -
    // Remove tablesorter and all classes
    +						
    // Remove tablesorter and all classes
     $("table").trigger("destroy");
     
     // Remove tablesorter and all classes but the "tablesorter" class on the table
    @@ -3416,7 +3502,7 @@ $("table").trigger("destroy", [false, callback]);
    Refresh the currently applied widgets. Depending on the options, it will completely remove all widgets, then re-initialize the current widgets or just remove all non-current widgets (v2.4).

    Trigger this method using either of the following methods (they are equivalent): -
    // trigger a refresh widget event
    +						
    // trigger a refresh widget event
     $('table').trigger('refreshWidgets', [doAll, dontapply]);
     
     // Use the API directly
    @@ -3440,55 +3526,32 @@ $.tablesorter.refreshWidgets(table, doAll, dontapply)
    filter: Get the currently applied filters in an array (v2.9): -
    -
    $.tablesorter.getFilters( $('table') ); // or use $('table.hasFilters') to make sure the table has a filter row
    - This method returns an array of filter values (e.g. [ '', '', '', '', '', '2?%' ]) or false if the selected table does not have a filter row. -
    -
    filter: Set the filters using this method; include a true boolean to actually apply the search (v2.9): -
    -
    // update filters, but don't apply the search
    -$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ] );
    -
    -// update filters, AND apply the search
    -$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ], true ); // this will now use the search method
    - This method returns true if the filters were sucessfully applied, or false if the table does not have a filter row. -
    -
    filter: Trigger the filter widget to reset the search criteria (v2.7.7).

    If you are using the filter_formatter option to add custom input elements, this function may not work on those columns. Please refer to the filter_formatter section for more details. -
    $(function(){
    +						
    $(function(){
       // this is the same code that the filter_reset element runs to clear out the filters.
       $('button').click(function(){
         $('table').trigger('filterReset');
    @@ -3498,37 +3561,11 @@ $.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ], true ); //
     				
    Example
    Added a resize event to the table headers - used by the stickyHeaders widget, but this is a public function available to any widget (v2.10). -

    - There is no built-in resize event for non-window elements, so when this function is active it triggers a resize event when the header cell changes size. So, if you are writing your own widget and need a header resize event, just include the jquery.tablesorter.widgets.js file, or just the extract the function from that file. Enable these triggered events as follows: -
    // Enable the triggering of header cell resize events as follows:
    -var table = $('table')[0],
    -    disable = false,
    -    options = {
    -      timer : 250 // header cell size is checked every 250 milliseconds (1/4 of a second)
    -    };
    -$.tablesorter.addHeaderResizeEvent( table, disable, options );
    Then use it in your custom widget as follows: -
    $(table).on('resize', function(event, columns){
    -  // columns contains an array of header cells that were resized
    -  // this seemed like a better idea than firing off a resize event for every
    -  // column when the table adjusts itself to fit within its container
    -  event.stopPropagation(); // optional
    -  // do something
    -  console.log( columns );
    -});
    To disable these resize events, use this code:
    // Disable resize event triggering:
    -var table = $('table')[0];
    -$.tablesorter.addHeaderResizeEvent( table, true );
    -
    Trigger the saveSort widget to clear any saved sorts for that specific table (v2.7.11).
    -
    $(function(){
    +						
    $(function(){
       $('button').click(function(){
         $('table').trigger('saveSortReset');
         return false;
    @@ -3549,7 +3586,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    Trigger the pager to change the page size (v2.7.4).
    -
    $(function(){
    +						
    $(function(){
       $('table').trigger('pageSize', 15);
     });
    Trigger the pager to change the current page (v2.7.7).
    -
    $(function(){
    +						
    $(function(){
       $('table').trigger('pageSet', 3);
     });
    Calling this method will reveal the entire table, remove the pager functionality, and hide the actual pager (v2.0.16).
    -
    $(function(){
    +						
    $(function(){
       $('table').trigger('destroy.pager');
     });
    The only way to restore the pager is to re-initialize the pager addon
    -
    $(function(){
    +						
    $(function(){
       $('table').tablesorterPager(pagerOptions);
     });
    This method will re-enable the pager, but only from the disabled state (v2.0.21.2).
    -
    $(function(){
    +						
    $(function(){
       $('table').trigger('enable.pager');
     });
    Example
    @@ -3622,12 +3658,12 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    TIP! Click on the link in the event column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
    - +
    - - + + @@ -3636,7 +3672,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    EventDescriptionLinkDescriptionLink
    This event fires when tablesorter has completed initialization. (v2.2).
    -
    $(function(){
    +						
    $(function(){
     
       // bind to initialized event BEFORE initializing tablesorter
       $("table")
    @@ -3661,7 +3697,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires immediately before tablesorter begins resorting the table.
    -
    $(function(){
    +						
    $(function(){
     
       // initialize the tablesorter plugin
       $("table").tablesorter();
    @@ -3679,7 +3715,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires immediately after the tablesorter header has been clicked, initializing a resort.
    -
    $(function(){
    +						
    $(function(){
     
       // initialize the tablesorter plugin
       $("table").tablesorter();
    @@ -3701,7 +3737,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires when tablesorter has completed resorting the table.
    -
    $(function(){
    +						
    $(function(){
     
       // initialize the tablesorter plugin
       $("table").tablesorter();
    @@ -3724,7 +3760,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires after tablesorter has completed updating. (v.2.3.9)
    This occurs after an "update", "updateAll", "updateCell" or "addRows" method was called, but before any callback functions are executed. -
    $(function(){
    +						
    $(function(){
     
       // initialize the tablesorter plugin
       $("table").tablesorter();
    @@ -3753,7 +3789,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    Event triggered when the filter widget has finished initializing (v2.4).

    - You can use this event to modify the filter elements (row, inputs and/or selects) as desired. Use it as follows:
    $(function(){
    +						You can use this event to modify the filter elements (row, inputs and/or selects) as desired. Use it as follows:
    $(function(){
       $('table').bind('filterInit', function(){
         $(this).find('tr.tablesorter-filter-row').addClass('fred');
       });
    @@ -3766,7 +3802,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    Event triggered when the filter widget has started processing the search (v2.4).

    - You can use this event to do something like add a class to the filter row. Use it as follows:
    $(function(){
    +						You can use this event to do something like add a class to the filter row. Use it as follows:
    $(function(){
       $('table').bind('filterStart', function(){
         $(this).find('tr.tablesorter-filter-row').addClass('filtering');
       });
    @@ -3779,7 +3815,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    Event triggered when the filter widget has finished processing the search (v2.4).

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

    - You can use this event to do something like modify content within the sticky header:
    $(function(){
    +						You can use this event to do something like modify content within the sticky header:
    $(function(){
       $('table').bind('stickyHeadersInit', function(){
         // this.config.widgetOptions.$sticky contains the entire sticky header table
         this.config.widgetOptions.$sticky.find('tr.tablesorter-headerRow').addClass('sticky-styling');
    @@ -3815,7 +3851,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires when the pager plugin begins to render the table on the currently selected page. (v2.0.7).
    -
    $(function(){
    +						
    $(function(){
     
       // initialize the sorter
       $("table")
    @@ -3843,7 +3879,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires when the pager plugin has completed its render of the table on the currently selected page. (v2.0.7).
    -
    $(function(){
    +						
    $(function(){
     
       // initialize the sorter
       $("table")
    @@ -3871,7 +3907,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires after all pager controls have been bound and set up but before the pager formats the table or loads any ajax data (v2.4.4).
    -
    $(function(){
    +						
    $(function(){
     
       $("table")
     
    @@ -3900,7 +3936,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event fires when the pager plugin has completed initialization (v2.4.4).
    -
    $(function(){
    +						
    $(function(){
     
       $("table")
     
    @@ -3931,7 +3967,7 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    This event may fire before the pagerComplete event when ajax processing is involved, or after the pagerComplete on normal use. See issue #153. -
    $(function(){
    +						
    $(function(){
     
       // initialize the sorter
       $("table")
    @@ -3958,6 +3994,942 @@ $.tablesorter.addHeaderResizeEvent( table, true );
    + +

    Tablesorter API

    + +
    + tablesorter has some useful internal variables & functions available through the API which can be used in custom coding, parsers and/or widgets.
    + +

    Variables

    + TIP! Click on the link in the variable column to reveal full details (or toggle|show|hide all) or double click to update the browser location. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    VariableTypeDescriptionLink
    ArrayThis is an array of all parser objects added using the addParser function. +
    +
    + If a specific parser needs to be retreived from this array, use the getParserById function. +
    +
    $.tablesorter.themesObjectThis is an object containing a list of specific class names to be applied to table elements. Please see the widget uitheme option for more details.
    ArrayThis is an array of all widget objects added using the addWidget function. +
    +
    + If a specific widget needs to be retreived from this array, use the getWidgetById function. +
    +
    Access the table configuration variables (config) using any of these methods: +
    +
    +
    // pure js, get the first table (zero index)
    +var config = document.getElementsByTagName('table')[0].config;
    +// or by table ID
    +var config = document.getElementById('mytable').config;
    +
    +// using jQuery, get first table (zero index)
    +var config = $('table')[0].config;
    +// or from the jQuery data
    +var config = $('#mytable').data('tablesorter');
    +
    +
    +
    ObjectInternal list of table contents (added v2.0.18) +
    +
    + This object contains the following:
    +
      +
    • tbody index +
        +
      • colMax +
          +
        • This contains an array of the maximum numerical value for each "numerically" parsed column.
        • +
        • Text columns will not have a defined value in this array.
        • +
        • Used when determining how to sort text within a numeric column.
        • +
        +
      • +
      • normalized +
          +
        • This contains an array of indexed table rows.
        • +
        • Within each row is an array of extracted, then parsed table contents for each column (plus one extra value; see the next comment).
        • +
        • It is important to note that the last value in the column array is actually the original row index value. This is used when resetting a column sort to its original unsorted order.
        • +
        • Note that all text values will be in lower case if the ignoreCase option is true.
        • +
        • This internal normalized content is what is actually sorted for maximum performance.
        • +
        +
      • +
      • row +
          +
        • This contains an array of jQuery row objects.
        • +
        • These rows are never in sort order, and are used when updating the table after sorting the normalized content. The indexing of these rows is cross-referenced within the normalized values - the extra column value within the row array. Hopefully that makes sense.
        • +
        +
      • +
      +
    • +
    • In version 3, I plan to: +
        +
      • Make the "one extra value" within the normalized row array to be an object.
      • +
      • Within this object will be the original row index, and a jQuery object of that row. Therefore removing the actual row section from the cache.
      • +
      • I have an array of normalized column content also stored in the cache to optimize the filter widget, but this may change in time.
      • +
      +
    • +
    + The table.config.cache variable is useful when writing widgets that need access to the parsed content. +
    +
    NumberInternal count of the number of table columns in the header (added v2.12) +
    +
    + This number is stored as a length (one-based), and takes into account any colspan and rowspan within the table head.
    +
    + Note that the table.config.columns variable does not always correlate with the indexing of the headers stored within table.config.$headers because of multiple rows and column or row spans. +
    +
    ArrayInternal list of each header's starting HTML (as text) +

    + This HTML snapshot is taken using the $headers jQuery object, and done before the headerTemplate is applied and before the onRenderTemplate and onRenderHeader callbacks are executed.
    +
    + This list is used by the $.tablesorter.restoreHeaders function to restore the table headers when the destroy method is executed. +
    +
    ArrayInternal list of each header element as selected using jQuery selectors in the selectorHeaders option. +
    +
    + This list contains DOM elements (not jQuery objects of each table header cell like the $headers variable) and is how the original version of tablesorter stored these objects. +
    + It is not used in the current version of tablesorter, and is only left in place for backwards compatibility with widgets written for the original tablesorter plugin. +
    +
    ArrayInternal list of all of the table's currently set parsers (objects copied from $.tablesorter.parsers). Here is a complete list of default parsers: +
    +
    + + + + + + + + + + + + + +
    sorter: falsedisable sort for this column.
    sorter: "text"Sort alpha-numerically.
    sorter: "digit"Sort numerically.
    sorter: "currency"Sort by currency value (supports "£$€¤¥¢").
    sorter: "ipAddress"Sort by IP Address.
    sorter: "url"Sort by url.
    sorter: "isoDate"Sort by ISO date (YYYY-MM-DD or YYYY/MM/DD; these formats can be followed by a time).
    sorter: "percent"Sort by percent.
    sorter: "usLongDate"Sort by date (U.S. Standard, e.g. Jan 18, 2001 9:12 AM or 18 Jan 2001 9:12 AM (new in v2.7.4)).
    sorter: "shortDate"Sort by a shortened date (see dateFormat; these formats can also be followed by a time).
    sorter: "time"Sort by time (23:59 or 12:59 pm).
    sorter: "metadata"Sort by the sorter value in the metadata - requires the metadata plugin.

    + Check out the headers option to see how to use these parsers in your table (example #1).
    Or add a header class name using "sorter-" plus the parser name (example #2), this includes custom parsers (example #3). +
    +
    + 1 + 2 + 3 +
    jQuery ObjectInternal list of all table header cells (added v2.8) +
    +
    + The header cells are targeted using the jQuery selector from the selectorHeaders option.
    +
    + Please note that the headers cells are simply an array of all header cells and should not be targeted using a column index. For example, given the following table thead markup, the header-index counts the header th cells and does not actually match the data-column index when extra rows and/or colspan or rowspan are included in any of the header cells: +
    <thead>
    +	<tr>
    +		<th colspan="4" data-column="0">header-index 0</th>
    +	</tr>
    +	<tr>
    +		<th data-column="0">header-index 1</th>
    +		<th data-column="1">header-index 2</th>
    +		<th data-column="2">header-index 3</th>
    +		<th data-column="3">header-index 4</th>
    +	</tr>
    +	<tr>
    +		<th colspan="2" data-column="0">header-index 5</th>
    +		<th colspan="2" data-column="2">header-index 6</th>
    +	</tr>
    +</thead>
    + So, in the above example, to target the header cell in the second table column (data-column index of 1), use the following code: table.config.$headers.filter('[data-column="1"]') or table.config.$headers.eq(2).
    +
    + The table.config.$headers variable is useful within callback functions or when writing widgets that target the table header cells. +
    +
    jQuery ObjectInternally stored jQuery object of the table (added v2.7.1) +
    +
    + The table.config.$table variable is useful within callback functions or when writing widgets that target the table. +
    +
    jQuery ObjectInternally stored jQuery object of the table tbodies (added v2.7.1) +
    +
    + jQuery object of sortable tbodies; the ones without the class name in the cssInfoBlock option.
    +
    + The table.config.$tbodies variable is useful within callback functions or when writing widgets that target the table. +
    +
    BooleanBoolean value indicating that tablesorter has been initialized on a table +
    +
    + This variable is not stored within the config, as the config would not be defined (an alternative method of determining if tablesorter has been initialized).
    +
    + Access it as follows: $('table')[0].hasInitialized. It is true while tablesorter is active on a table, and false if tablesorter was destroyed. +
    +
    Access the widgetOptions (wo) using any of these methods: +
    +
    +
    // pure js, get the first table (zero index)
    +var wo = document.getElementsByTagName('table')[0].config.widgetOptions;
    +// or by table ID
    +var wo = document.getElementById('mytable').config.widgetOptions;
    +
    +// using jQuery, get first table (zero index)
    +var wo = $('table')[0].config.widgetOptions;
    +// or from the jQuery data
    +var wo = $('#mytable').data('tablesorter').widgetOptions;
    +
    +
    +
    jQuery ObjectOnly available when the filter widget is active. This variable contains all external search inputs with data-column="all", bound using the bindSearch function. +
    +
    + The table.config.widgetOptions.filter_$anyMatch variable contains one more more search inputs, and is dynamically updated if the bindSearch function is called; make sure to set the flag to force a new search so that the values of the altered filters is updated appropriately. +
    +
    jQuery ObjectOnly available when the filter widget is active. This variable contains all table cells within the filter row. +
    +
    + Use the table.config.$filters variable when access to filters is needed. Note! This variable contains the table cell and not the actual input because the filter_formatter function allows adding other types of value selectors (e.g. jQuery UI slider). +
    +
    jQuery ObjectOnly available when the filter widget is active. This variable contains all external search inputs bound using the bindSearch function. +
    +
    + The table.config.widgetOptions.filter_$externalFilters variable contains an array of jQuery objects pointing to all external inputs, even if the bindSearch function is used multiple times. +
    +
    jQuery ObjectOnly available when the filter widget is active. This variable contains all external search inputs bound using the bindSearch function. +
    +
    + The table.config.widgetOptions.filter_$externalFilters variable contains an array of jQuery objects pointing to all external inputs, even if the bindSearch function is used multiple times. +
    +
    jQuery ObjectOnly available when the stickyHeaders widget (not the css3 version) is active. +
    +
    + The table.config.widgetOptions.$sticky variable contains a jQuery object pointing to a cloned table containing the sticky header. The table contained within this variable has a class name of "containsStickyHeaders" versus the original table with a class name of "hasStickyHeaders". +
    +
    + +
    +

    Functions

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

    + Use it as follows: +
    $.tablesorter.isProcessing( table, toggle, $ths );
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • toggle - Boolean flag.
    • +
    • $ths - jQuery object of targetted header cells (optional; if excluded all header cells are targetted).
    • +
    + When calling the function, set the toggle option to add (true) or remove (false) process indicators. Include any specific header cells within the $ths variable with which to add the process indicator. When $ths is not defined and a sort is applied, the currently sorted header cells will show process indicators.
    +
    + All this function does is add or remove a class name of "tablesorter-processing" and the class name contained within the cssProcessing option.
    +
    + Here is a basic example of how this function is used: +
    $('table').bind('sortBegin sortEnd', function(event){
    +	// this is included with the basic functionality of tablesorter
    +	$.tablesorter.isProcessing( this, event === 'sortBegin' );
    +});
    + Please note that currently the processing icons do not animate (see issue #158). This is due to javascript being a single-threaded, meaning it only does one task at a time, and maximizing the sorting script. So lots of processing is needed to sort & rebuild the table and thus it has no time for animation. If someone knows of a better solution, please share! +
    +
    This function empties ALL of the table tbodies. +

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

    + Use it as follows: +
    $.tablesorter.bindEvents( table, $headers );
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • $headers - jQuery object of targetted cells.
    • +
    + This function allows you to bind the same header event listeners to external headers cells (usually clones of the original table). This includes the triggered sort event, left click (only) to sort, ignoring long clicks (> 250ms), pressing enter to trigger a sort (must have focus and a tabindex attribute) and cancelling selection of text (if the option is set).
    +
    + To ensure the columns match the original table, include data-column attributes pointing to the desired column.
    +
    + Here is a basic example of how this function is used: +
    var $table = $('table'),
    +	// make a copy of the table
    +	$clonedTable = $table.clone().addClass('clonedTable').insertAfter($table);
    +// remove stuff we don't need in the clone
    +$clonedTable.find('tfoot,tbody').remove();
    +// bind events to the cloned headers
    +$.tablesorter.bindEvents( $table, $clonedTable.find('th') );
    +
    +
    This function restores the table headers cells with their original content. +

    + The original header cell content is saved, within the headerContent variable array, before the headerTemplate is applied and before the onRenderTemplate and onRenderHeader callbacks are executed.
    +
    + Use it as follows: +
    $.tablesorter.restoreHeaders( table );
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    + Please note that only header cells that still contain a div with a class name of tablesorter-header-inner will have their contents restored; it assumes that the contents have already been restored. +
    +
    This function completely removes tablesorter, including all widgets, associated data & event handlers from the table. +

    + Use it as follows: +
    $.tablesorter.destroy( table, removeClasses, callback );
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • removeClasses - Boolean flag
    • +
    • callback - Function executed once tablesorter has been removed.
    • +
    + When calling the function, set the removeClasses option to true to include removing of the "tablesorter" class name, tablesorter theme name (e.g. "tablesorter-blue") and the class name applied by the tableClass option. The callback function only provides a table (DOM element only) parameter.
    +
    + Here is a basic example of how this function is used: +
    $.tablesorter.destroy( table, true, function(table){
    +	alert('tablesorter has been removed! No sort for you!');
    +});
    + Please note that only header cells that still contain a div with a class name of tablesorter-header-inner will have their contents restored; it assumes that the contents have already been restored. +
    +
    This function sorts the a & b parameter using a natural sort. +

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

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

    + Use it as follows: +
    $.tablesorter.replaceAccents(string);
    +
      +
    • string - a string to process & replace accented characters.
    • +
    + Here is a basic example of how this function is used: +
    $.tablesorter.replaceAccents("áàâãä"); // result: "aaaaa"
    + This function is used when the sortLocaleCompare option is set to true. Please refer to the option and the demo for more details on the defaults values and how to add more accented characters. +
    +
    This function returns a boolean value if the value is contained within an array. +

    + Use it as follows: +
    $.tablesorter.isValueInArray(value, array);
    +
      +
    • value - value to find within the array.
    • +
    • array - array (sortList) to search for the value.
    • +
    + Sadly, this function has limited usefulness outside of tablesorter. It is only meant to search a sortList array and determine if a column (value) is already contained within it. Here is a basic example of how this function is used: +
    var sortList = [ [0,0], [1,0] ];
    +// result: true
    +$.tablesorter.isValueInArray(1, sortList);
    +
    +
    This function allows the adding of custom parser scripts to the tablesorter core. +

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

    + Access it as follows: +
    $.tablesorter.getParserById(name);
    +
      +
    • name - the name (or id) of the parser.
    • +
    + Use this function as follows: +
    var parser = $.tablesorter.getParserById("currency"),
    +	value = parser.format('100%'); // returns 100 (number type, not a string)
    +
    +
    This function allows the adding of custom widget scripts to the tablesorter core. +

    + Access it as follows: +
    $.tablesorter.addWidget(myWidget);
    +
      +
    • myWidget - object containing widget code.
    • +
    + The myWidget object must contain a proper template. The template must include an id and format blocks. The priority, options, init and remove blocks are optional. Please refer to the writing custom widgets demo page for more details & an example. +
    +
    This function returns the named widget object. +

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

    + Use it as follows: +
    $.tablesorter.applyWidget( table, init );
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • init - optional, boolean initialization flag.
    • +
    + The init flag is only set to true to extend the default option values from the widget options block. If the widget(s) have already been applied to the table, just leave this parameter undefined.
    +
    + This function is called when the applyWidgets method is triggered. +
    +
    This function removes, then reapplies all currently selected widgets on a table. +

    + Use it as follows: +
    $.tablesorter.refreshWidgets( table, doAll, dontapply );
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • doAll - optional, boolean flag.
    • +
    • dontapply - optional, boolean flag.
    • +
    + The doAll flag is set to true if all widgets contained with the global $.tablesorter.widgets array are to be removed.
    +
    + This function is called when the refreshWidgets method is triggered. +
    +
    This functions gets the sorter, string, empty, etc options for each column from jQuery data, metadata, header option or header class name ("sorter-false"). +

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

    + Use it as follows: +
    $.tablesorter.formatFloat(string, table);
    +
      +
    • string - a string possibly containing a number.
    • +
    • table - table DOM element (or jQuery object) of table.
    • +
    + If string is empty, not a string type, or not a number (after processing), the string itself is returned.
    +
    + This function uses the usNumberFormat option to determine if either commas or decimals are removed before converting the value within the string parameter into a number type variable. This function does not use the $.tablesorter.isDigit function.
    +
    + Any numbers wrapped within parenthesis are converted into negative numbers; but any other symbols (e.g. currency) are not removed and will cause this function to determine the string as a non-number (e.g. "$1.25" will be returned as a string).
    +
    + Use this function as follows: +
    // result: -2345.67 if usNumberFormat option is true
    +$.tablesorter.formatFloat( "(2,345.67)", table );
    +
    +
    This function determines if a string contains a number after removing commas, periods, quotes and spaces. +

    + Use it as follows: +
    $.tablesorter.isDigit(string);
    +
      +
    • string - a string possibly containing a number.
    • +
    + This function will return a boolean value of true if the string parameter contains a number after all commas, decimals, quotes and spaces are removed, and still allow plus or minus signs, or the number wrapped in parenthesis (negative values).
    +
    + Use this function as follows: +
    // boolean value of true returned
    +$.tablesorter.isDigit( "(2,345.67)" );
    +
    +
    Widget Functions
    This filter widget function allows binding external search filters to the table (v2.13.3; v2.15). +

    + Access it as follows: +
    $.tablesorter.filter.bindSearch(table, $els, false);
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • $els - jQuery object of all input (search) elements to bind.
    • +
    • false - boolean flag to force a new search.
    • +
    + The external elements ($els) will allow searching the table using "search" and "keyup" events (enter to start & escape to cancel the search), and uses the filter_liveSearch option, or delayed search.
    +
    + Include a data-column="#" attribute (where # is the column number) in the search input, to specify to which column the search should apply ~ see this demo for a full example. Warning!, if no data-column attribute is added to the input, the input will be ignored.
    +
    + In v2.15, use a data-column="all" to bind an external any-match search filter; but note that adding an external any-match filter using this method will not override the filter set by the filter_external option.
    +
    + The third function parameter, false, is optional. When set to false it forces the inputs to update their values (same as setting the apply flag when using the setFilters function), and reapplies (forces) the current search to be applied again, even if the filter values have not changed; this allows changing the data column attribute dynamically. See the filter external inputs demo for an example.
    +
    + Warning! If the third parameter is set to true the saved internal filters (config.$filters) will be replaced - not recommended! +
    +
    This filter widget function allows getting an array of the currently applied filters (v2.9; v2.15) +

    + Access it as follows: +
    $.tablesorter.getFilters(table, flag);
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • flag - boolean flag (optional; false by default), added v2.15
    • +
    + Use this function as follows:
    +
    // use $('table') or $('table.hasFilters') to make sure the table has a filter row
    +// only required if the stickyHeaders or scroller widget is being used (they duplicate the table)
    +$.tablesorter.getFilters( $('table') );
    + This function returns an array of filter values (e.g. [ '', '', '', '', '', '2?%' ]), or false if the selected table does not have a filter row. It will also return an additional parameter if an external input with data-column="all" containing the value used when matching any table column.
    +
    + In v2.15, this function will also return values from any external filters (set either by the filter_external option or using the bindSearch function) - with or without an internal filter row.
    +
    + If the second parameter is set to true, it forces the function to get all of the current filter values directly from the inputs. Otherwise, by default, the function returns the last search as found in this stored data $('table').data('lastSearch');. +
    +
    This filter widget function allows setting of the filters; include a true boolean to actually apply the search (v2.9; v2.15): +

    + Access it as follows: +
    $.tablesorter.setFilters(table, filter, apply);
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • filter - array of filter values to apply to the table.
    • +
    • apply - boolean flag, if false (default setting), the input values are updated, but not searched for within the table.
    • +
    + Use this function as follows:
    +
    // update filters, but don't apply the search
    +$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ] );
    +
    +// update filters, AND apply the search
    +$.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ], true ); // this will now use the search method
    + This function returns true if the filters were sucessfully applied, or false if the table does not have a filter row.
    +
    + As of v2.15, this function will also set values in any external filters (set either by the filter_external option or using the bindSearch function). An additional search parameter can be included to match any column, but please include an external input with data-column="all" using the bindSearch function so your users will know that a search has been applied.
    +
    + Also, changed is that when a true value is passed as a third parameter, the search is forced to refresh on the table; otherwise, if the filters set in the search exactly match the previous search, it would be ignored - this was added to prevent numerous ajax calls with exactly the same search or sort parameters (when using the pager). +
    +
    This resizable widget function allows resetting column width changes and clearing out the saved set widths (v2.4; v2.15) +

    + Use it as follows: +
    $.tablesorter.resizableReset(table);
    +
      +
    • table - table DOM element (or jQuery object) of table(s).
    • +
    + This function is used when the user right-clicks on the table header. +
    +
    Added a resize event to the table headers - used by the stickyHeaders widget, but this is a public function available to any widget (v2.10). +

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

    + Access it as follows: +
    $.tablesorter.storage(table, key, value, options);
    +
      +
    • table - table DOM element (or jQuery object) of table.
    • +
    • key - name of the variable to save
    • +
    • value - value of the variable that is saved (for saving only); set to null if wanting to get a value with options.
    • +
    • options - storage options; see below
    • +
    + This function attempts to give every table a unique identifier using both the page url and table id (or index on the page if no id exists), by default. Here is a usage example and a look at what is stored within the local storage: +
    $.tablesorter.storage( $('#tablesorter-demo')[0], 'test', '123');
    +// stored as, test = : {"/tablesorter/docs/":{"tablesorter-demo":"123"}}
    +
    +
    + The saved table url & id can be overridden by setting table data attributes data-table-page (url) and data-table-group (id), as in this sample markup: +
    <table class="tablesorter" data-table-page="mydomain" data-table-group="financial">...</table>)
    + To change the default data attributes, use the options to modify them as follows:
    $.tablesorter.storage( table, key, value, {
    +  // table id/group id
    +  id  : 'group1',
    +  // this group option sets name of the table attribute with the ID;
    +  // but the value within this data attribute is overridden by the above id option
    +  group: 'data-table-group'
    +
    +  // table pages
    +  url : 'page1',
    +  // this page option sets name of the table attribute with the page/url;
    +  // but the value within the data attribute is overridden by the above url option
    +  page: 'data-table-page'
    +});
    + The priority of table ID settings is as follows: +
      +
    1. options.id setting
    2. +
    3. Table data attribute (data-table-group by default) value
    4. +
    5. Table id
    6. +
    7. Index of the table on the page
    8. +
    + The priority of table url (group) settings is as follows: +
      +
    1. options.url setting
    2. +
    3. Table data attribute (data-table-page by default) value
    4. +
    5. fixedUrl option value
    6. +
    7. window.location.pathname
    8. +
    +
    + The fixedUrl option allows you to override the current page url (it doesn't need to be a url, just some constant value) and save data for multiple tables across a domain. The value from this option has a lower priority than the options id or group settings (see priority list above).
    +
    + When using the storage utility to get a value and use custom table options, set the value parameter to null.
    +
    + Lastly, this storage utility function needs the parseJSON function available in jQuery v1.4.1+. +
    +
    +

    Download

    diff --git a/docs/js/demo-build-table.js b/docs/js/demo-build-table.js index 5559e533..b51f4437 100644 --- a/docs/js/demo-build-table.js +++ b/docs/js/demo-build-table.js @@ -1,8 +1,4 @@ $(function(){ - $('.accordion').accordion({ - heightStyle: 'content', - collapsible : true - }); // *************************** // ARRAY diff --git a/docs/js/docs.js b/docs/js/docs.js index 7d21d352..e9dc74ca 100644 --- a/docs/js/docs.js +++ b/docs/js/docs.js @@ -59,6 +59,7 @@ $(function(){ $('.permalink').dblclick(function(){ clicked = true; window.location.hash = '#' + $(this).closest('tr')[0].id; + showProperty(); setTimeout(function(){ clicked = false; }, 500); return false; }); @@ -89,10 +90,39 @@ $(function(){ } }); + $t = $('.accordion'); + if ($t.length) { + var hashId = 0; + if (window.location.hash) { + $t.children('h3').each(function(i){ + var txt = $(this).text().toLowerCase().replace(/\s+/g,'_'); + this.id = txt; + if (txt === window.location.hash.slice(1)) { + hashId = i; + } + }); + } + $t.accordion({ + active: hashId, + animate: false, + heightStyle: 'content', + collapsible: true, + create: function( event, ui ) { + $t.children('h3').each(function(i){ + this.id = $(this).text().toLowerCase().replace(/\s+/g,'_') + $(this).before(''); + }); + $t.find('.accordion-link').click(function(){ + $t.accordion( "option", "active", $(this).data('index') ); + }); + } + }); + } + }); function showProperty(){ - var prop, h = window.location.hash; + var prop, $t, h = window.location.hash; if (h) { prop = $(h); if (prop.length && prop[0].tagName !== "TABLE") { @@ -102,8 +132,10 @@ function showProperty(){ } // move below sticky header; added delay as there could be some lag setTimeout(function(){ - if (/options/.test(prop.closest('table').attr('id') || '')) { - $('body').scrollTop( prop.position().top - 28 ); + $t = prop.closest('table'); + h = $t[0].config.widgetOptions.$sticky.height() || 27; + if ($t.hasClass('options') || $t.hasClass('api')) { + $('body').scrollTop( prop.position().top - h ); } }, 200); } @@ -111,14 +143,12 @@ function showProperty(){ } $(window).load(function(){ - if ($('#root').length) { $(window).bind('hashchange', function(){ showProperty(); }); showProperty(); } - }); // append hidden parsed value to cell diff --git a/js/extras/jquery.quicksearch.js b/js/extras/jquery.quicksearch.js new file mode 100644 index 00000000..ee783ace --- /dev/null +++ b/js/extras/jquery.quicksearch.js @@ -0,0 +1,191 @@ +/* jQuery Quicksearch plugin + by riklomas https://github.com/riklomas/quicksearch + Modified to include childRows (for tablesorter) + + See http://stackoverflow.com/q/20342203/145346 for + more details +*/ +(function($, window, document, undefined) { + $.fn.quicksearch = function (target, opt) { + + var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({ + delay: 100, + selector: null, + stripeRows: null, + loader: null, + noResults: '', + childRow: 'tablesorter-childRow', // include child row with search results + matchedResultsCount: 0, + bind: 'keyup', + onBefore: function () { + return; + }, + onAfter: function () { + return; + }, + show: function () { + this.style.display = ""; + }, + hide: function () { + this.style.display = "none"; + }, + prepareQuery: function (val) { + return val.toLowerCase().split(' '); + }, + testQuery: function (query, txt, _row) { + for (var i = 0; i < query.length; i += 1) { + if (txt.indexOf(query[i]) === -1) { + return false; + } + } + return true; + } + }, opt); + + this.go = function () { + + var i = 0, + numMatchedRows = 0, + noresults = true, + query = options.prepareQuery(val), + val_empty = (val.replace(' ', '').length === 0); + + for (var i = 0, len = rowcache.length; i < len; i++) { + if (val_empty || options.testQuery(query, cache[i], rowcache[i]) || + ($(rowcache[i]).hasClass(options.childRow) && $(rowcache[i > 1 ? i - 1 : 0]).is(':visible'))) { + options.show.apply(rowcache[i]); + noresults = false; + numMatchedRows++; + } else { + options.hide.apply(rowcache[i]); + } + } + + if (noresults) { + this.results(false); + } else { + this.results(true); + this.stripe(); + } + + this.matchedResultsCount = numMatchedRows; + this.loader(false); + options.onAfter(); + + return this; + }; + + /* + * External API so that users can perform search programatically. + * */ + this.search = function (submittedVal) { + val = submittedVal; + e.trigger(); + }; + + /* + * External API to get the number of matched results as seen in + * https://github.com/ruiz107/quicksearch/commit/f78dc440b42d95ce9caed1d087174dd4359982d6 + * */ + this.currentMatchedResults = function() { + return this.matchedResultsCount; + }; + + this.stripe = function () { + + if (typeof options.stripeRows === "object" && options.stripeRows !== null) + { + var joined = options.stripeRows.join(' '); + var stripeRows_length = options.stripeRows.length; + + jq_results.not(':hidden').each(function (i) { + $(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]); + }); + } + + return this; + }; + + this.strip_html = function (input) { + var output = input.replace(new RegExp('<[^<]+\>', 'g'), ""); + output = $.trim(output.toLowerCase()); + return output; + }; + + this.results = function (bool) { + if (typeof options.noResults === "string" && options.noResults !== "") { + if (bool) { + $(options.noResults).hide(); + } else { + $(options.noResults).show(); + } + } + return this; + }; + + this.loader = function (bool) { + if (typeof options.loader === "string" && options.loader !== "") { + (bool) ? $(options.loader).show() : $(options.loader).hide(); + } + return this; + }; + + this.cache = function () { + + jq_results = $(target); + + if (typeof options.noResults === "string" && options.noResults !== "") { + jq_results = jq_results.not(options.noResults); + } + + var t = (typeof options.selector === "string") ? + jq_results.find(options.selector) : $(target).not(options.noResults); + cache = t.map(function () { + return e.strip_html(this.innerHTML); + }); + + rowcache = jq_results.map(function () { + return this; + }); + + /* + * Modified fix for sync-ing "val". + * Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1 + * */ + val = val || this.val() || ""; + + return this.go(); + }; + + this.trigger = function () { + this.loader(true); + options.onBefore(); + + window.clearTimeout(timeout); + timeout = window.setTimeout(function () { + e.go(); + }, options.delay); + + return this; + }; + + this.cache(); + this.results(true); + this.stripe(); + this.loader(false); + + return this.each(function () { + + /* + * Changed from .bind to .on. + * */ + $(this).on(options.bind, function () { + + val = $(this).val(); + e.trigger(); + }); + }); + + }; + +}(jQuery, this, document)); diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index 4844f37d..c841ff26 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -630,7 +630,7 @@ ts.filter = { ts.filter.checkFilters(table, filters); }); // filter widget initialized - wo.filter_Initialized = true; + wo.filter_initialized = true; c.$table.trigger('filterInit'); }, setDefaults: function(table, c, wo) { diff --git a/js/widgets/widget-columnSelector.js b/js/widgets/widget-columnSelector.js index 3e4930f0..848c5957 100644 --- a/js/widgets/widget-columnSelector.js +++ b/js/widgets/widget-columnSelector.js @@ -1,4 +1,4 @@ -/* Column Selector/Responsive table widget (beta) for TableSorter 12/17/2013 (v2.14.6) +/* Column Selector/Responsive table widget (beta) for TableSorter 12/17/2013 (v2.15.0) * Requires tablesorter v2.8+ and jQuery 1.7+ * by Justin Hallett & Rob Garrison */ diff --git a/js/widgets/widget-cssStickyHeaders.js b/js/widgets/widget-cssStickyHeaders.js index 3d518774..00316c1b 100644 --- a/js/widgets/widget-cssStickyHeaders.js +++ b/js/widgets/widget-cssStickyHeaders.js @@ -1,4 +1,4 @@ -/*! tablesorter CSS Sticky Headers widget - updated 12/17/2013 (v2.14.6) +/*! tablesorter CSS Sticky Headers widget - updated 12/17/2013 (v2.15.0) * Requires a modern browser, tablesorter v2.8+ */ /*global jQuery: false, unused:false */ diff --git a/js/widgets/widget-editable.js b/js/widgets/widget-editable.js index 66bb7b55..f16f0319 100644 --- a/js/widgets/widget-editable.js +++ b/js/widgets/widget-editable.js @@ -1,4 +1,4 @@ -/*! tablesorter Editable Content widget - updated 11/25/2013 (core v2.14.2) +/*! tablesorter Editable Content widget - updated 1/24/2014 (core v2.15.0) * Requires tablesorter v2.8+ and jQuery 1.7+ * by Rob Garrison */ diff --git a/js/widgets/widget-grouping.js b/js/widgets/widget-grouping.js index bc854364..76f9bbdd 100644 --- a/js/widgets/widget-grouping.js +++ b/js/widgets/widget-grouping.js @@ -1,4 +1,4 @@ -/*! tablesorter Grouping widget - updated 12/18/2013 (core v2.14.6) +/*! tablesorter Grouping widget - updated 12/18/2013 (core v2.15.0) * Requires tablesorter v2.8+ and jQuery 1.7+ * by Rob Garrison */ diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index 64ecd25c..216c313f 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -1,4 +1,4 @@ -/* Pager widget (beta) for TableSorter 12/14/2013 (v2.14.4) */ +/* Pager widget (beta) for TableSorter 1/16/2014 (v2.15.0) */ /*jshint browser:true, jquery:true, unused:false */ ;(function($){ "use strict";