Tablesorter - Appendices - Web Development with jQuery (2015)

Web Development with jQuery (2015)

Part IV. Appendices

Appendix T. Tablesorter

Tablesorter Options

Option

Description

Type

cancelSelection

Determines whether text in table header <th> elements should be selectable.
Default value: true

Boolean

cssAsc

The class name to apply to a table header <th> that represents a column sorted ascending.
Default value: 'headerSortUp'

String

cssDesc

The class name to apply to a table header <th> that represents a column sorted descending.
Default value: 'headerSortDown'

String

cssHeader

The class name applied to a table header <th> representing a column in an unsorted state.
Default value: 'header'

String

debug

Determines whether additional debugging information should be displayed, which is useful for development.
Default value: false

Boolean

headers

An object representing options that can be provided for each column. The object is defined counting each column offset from zero. The only option allowed at the time of this writing is indicating whether a column is sortable.
An example object that disables sorting on the first column:
headers : {
0 : {
sorter : false
}
}
Default value: null

Object

sortForce

This option is used to assist with multicolumn sorting. For example, it can assist with sorting by name after sorting by other criteria such as by date or account balance or other criteria. The value used to specify this option follows the same pattern as the sortList option.
Default value: null

Array

sortList

This option defines an initial sorting for columns. Each column is defined in an array in order from the column sorted first to the column sorted last. For example:
sortList : [
[0, 0],
[2, 1]
]
This setting sorts first by the first column, ascending. The first column is offset zero with another zero for ascending [0, 0]. Then the third column is sorted descending. The third column is offset two followed by one for descending [2, 1].
Default value: null

Array

sortMultiSortKey

This option indicates which keyboard modifier to use to select more than one column for sorting.
Default value: 'shiftKey'

String

textExtraction

Defines which method to use to grab text from a table cell for sorting. String options include 'simple' and 'complex'. 'simple' does not take into account any markup that might be present preceding table cell text. 'complex' takes markup into account but can be slow when dealing with large data sets.
An additional option is to write your own function for text extraction. This function has a signature like so:
function(node)
{
return $(node).text();
}
Keep in mind that using jQuery over JavaScript directly will impact performance on a large table.
Default value: 'simple'

String, Function

widthFixed

Determines whether fixed widths should be used for columns.
Note this can also be accomplished with the CSS table-layout: fixed; declaration applied to the <table> element.
Default value: false

Boolean