tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.
- Because of the change to the internal cache, the tablesorter v2.16+ core, filter widget and pager (both plugin & widget) will only work with the same version or newer files.
- See the full documentation.
- All of the original document pages have been included.
- Information from my blog post on undocumented options and lots of new demos have also been included.
- Change log moved from included text file into the wiki documentation.
- Basic alpha-numeric sort Demo.
- Links to demo pages can be found within the main documentation.
- More demos & playgrounds - updated in the wiki pages.
- Multi-column alphanumeric sorting and filtering.
- Multi-tbody sorting - see the options table on the main document page.
- Supports Bootstrap v2 and 3
- Parsers for sorting text, alphanumeric text, URIs, integers, currency, floats, IP addresses, dates (ISO, long and short formats) & time. Add your own easily.
- Inline editing - see demo
- Support for ROWSPAN and COLSPAN on TH elements.
- Support secondary "hidden" sorting (e.g., maintain alphabetical sort when sorting on other criteria).
- Extensibility via widget system.
- Cross-browser: IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+, Chrome 5.0+.
- Small code size, starting at 25K minified
- Works with jQuery 1.2.6+ (jQuery 1.4.1+ needed with some widgets).
- Works with jQuery 1.9+ ($.browser.msie was removed; needed in the original version).
- Copyright (c) 2007 Christian Bach.
- Original examples and docs at: http://tablesorter.com.
- Dual licensed under the MIT and GPL licenses.
- Get all files
- Use bower:
bower install jquery.tablesorter
- Use node.js:
npm install tablesorter
- CDNJS: https://cdnjs.com/libraries/jquery.tablesorter
- Plugin for Rails. Maintained by themilkman.
- Bootsole (OOP templating engine using tablesorter) by alexweissman.
If you would like to contribute, please...
- Fork.
- Make changes in a branch & add unit tests.
- Run
grunt test
(if qunit fails, run it again - it's fickle). - Create a pull request.
- Big shout-out to Nick Craver for getting rid of the
eval()
function that was previously needed for multi-column sorting. - Big thanks to thezoggy for helping with code, themes and providing valuable feedback.
- Big thanks to ThsSin- for taking over for a while and also providing valuable feedback.
- Also extra thanks to christhomas and Lynesth for help with code.
- And, of course thanks to everyone else that has contributed, and continues to contribute to this forked project!
- Check the FAQ page.
- Search the main documentation (click the menu button in the upper left corner).
- Search the issues to see if the question or problem has been brought up before, and hopefully resolved.
- If someone is available, ask your question in the
#tablesorter
IRC channel at freenode.net. - Ask your question at Stackoverflow using a tablesorter tag.
- Please don't open a new issue unless it really is an issue with the plugin, or a feature request. Thanks!
View the complete change log here.
Version 2.20.1 (2/20/2015)
- Filter: Fixed a major issue with the filter widget not working properly.
Version 2.20.0 (2/20/2015)
- Grunt build process
- Added code to use npm & grunt to build a custom widget file.
- An
example.json
file has been added as an example of how to set up a custom build file; see the Customize wiki page for more details. - With each build, the following occurs:
jquery.tablesorter.js
is copied to thedist/js
folder.- All
less
files are copied to thedist/css/less
folder. - All images, including the pager icons, is copied into the
dist/css/images
folder. - A
jquery.tablesorter.widgets.js
file is created from the selected widgets into thedist/js
folder, then copied back to thejs
folder to allow jsFiddle demos to continue working. - A
.min.js
file is created for the core & widget file in thedist/js
folder, then all parsers & widgets are compressed separately in thedist/js/parsers
anddist/js/widgets
folder, respectively. - A
.min.css
file is created for all themes, dragtable, filter-formatter & pager styles. - The black-ice theme within the distribution folder is renamed to
theme.blackice.min.css
(no dash). See issue #785.
- Files - the following changes to files have been made for the Grunt build process (this might break a few jsFiddle demos):
jquery.metadata.js
has been moved into thejs/extras
folder.jquery.tablesorter.widgets-filter-formatter.js
- moved to the
js/widgets
folder - Broken into two files, and renamed to
widget-filter-formatter-html5.js
andwidget-filter-formatter-jui.js
.
- moved to the
jquery.tablesorter.widgets-filter-formatter-select2.js
- Moved into the
js/widgets
folder. - Renamed to
widget-filter-formatter-select2.js
- Moved into the
jquery.tablesorter.widgets.js
- Has been broken up into separate widget files:
widget-column.js
,widget-filter.js
,widget-resizable.js
,widget-saveSort.js
,widget-stickyHeaders.js
,widget-storage.js
andwidget-uitheme.js
. - A default build creates a file of the above widgets combined in the
dist/js
folder. - A copy of this newly created combined widget file is then copied back to the
js/
folder to allow external demos (jsFiddle) to still work.
- Has been broken up into separate widget files:
- Resolve jQuery unbinding issue
-
When unbinding events in jQuery versions 1.7 to 1.8, if an event list contains double spaces
$('table').unbind('a b');
all events will be removed from that element (see this demo)!
-
Unbinding of events updated in the Core plugin & pager addon, and the following widgets: cssStickHeaders, editable, filter, formatter, math, staticRow & stickyHeaders.
-
- Modified
config.cache
to only include non-info only tbodies.- This modification effects the core & the following widgets: chart, filter, grouping, pager (widget & addon).
- Thanks to prijutme4ty for working on this change.
- See pull request #822 for more details.
- Core
- Add
cssNoSort
option. Add the class name from that option to any element within a header will prevent a click on that element and any containing elements from causing a sort. - Remove
cssAllowClicks
option. It wasn't working as intended and actually prevented sorting. It was replaced by it's opposite, thecssNoSort
option. - Make core work with jQuery v1.2.6, again.
- Make
getElementText
function public; with a bug fix from prijutme4ty in pull.
- Add
- Docs
- Add a css column & row highlighting demo.
- Update jQuery UI & remove "latest" from the file name.
- Filter
- Prevent javascript error when empty rows (
<tr></tr>
) are included in the tbody. Fixes issue #819. - Prevent javascript error when performing an "any-match" search triggered on the table without an included external
data-column="all"
input. - Ensure that an "any-match" search is a string value.
- Added "any-match" specific column search by using
#:{query}
where#
is a one-based column index and{query}
is the query. Thanks to MaksimProgr for providing the code in pull request #817. This also fixes issue #747. - Added
filter_columnAnyMatch
option to allow disabling the "any-match" specific column search.
- Prevent javascript error when empty rows (
- Pager
- Fix initial start page default for the widget only.
- Update pager
ajaxProcessing
code demo to prevent unordered JSON keys from adding content to incorrect columns. Fixes issue #818.
- Parsers
- Fix checkbox parser, in the
parser-input-select.js
file, so that it now properly updates when changed.
- Fix checkbox parser, in the
Version 2.19.1 (2/9/2015)
- Core
- Replace all double quote with a single - OCD made me do it!
- Save raw table cell text (unparsed) into the cache.
- Core/Widgets
- Fix a problem with event unbinding when using jQuery versions 1.7 & 1.8.
- When an
unbind
(oroff
) event string contains an untrimmed or central double space, all events on the element become unbound. - See jQuery bug or this demo.
- Updated the core, and the cssStickyHeaders, editable, filter, formatter, math, pager (addon & widget), staticRow widgets and stickyHeaders widgets.
- Chart
- Add more data points.
- Filter
- Add a second custom filter search type example which allows finding if the query number is within a range.
- Math
- Add
math_event
option.
- Add
- StaticRow
- Add
staticRow_event
option.
- Add
Version 2.19.0 (2/7/2015)
- Core
- Add AMD/browserify support; See pull #786, thanks to mwiencek!
- Resort variable can now contain a new sort. See issue #782.
- Prevent resort when
serverSideSorting
istrue
. Fixes issue #764. - Add
resort
option. It is used as the fallback value when no resort parameter is included with the "updateAll", "update", "addRows" and "updateCell" methods. - Add
removeWidget
function which calls the widgetremove
function & removes the named widget from theconfig.widget
option. - A
refreshing
parameter was added to the widget remove function; whentrue
it indicates that arefreshWidgets
method was triggered and that the widget will only be temporarily removed. - Make fixColumnWidth a public function (
$.tablesorter.fixColumnWidth
). Calling it will refresh set column widths dynamically. See issue #680. - The default
textExtraction
function has been optimized -node.innerText
was completely removed as it is significantly slower in IE. - Modified the "updateCell" method to not reapply widgets if the resort parameter is
false
; this may resolve issue with widgets causing elements to lose focus. - Updated the
refreshWidgets
to use theremoveWidget
function. Once the widgets have been refreshed a"refreshComplete"
event will be triggered. - Updated
applyWidget
function to allow passing a callback function. - Prevent adding multiple icons on refresh.
- Trim header text added to aria label.
- The
updateAll
method no longer restores headers since it is only refreshing. - Fix parser check while building cache which can cause unresolving parsers in case the first tbody is empty and remaining tbodies have less rows than a number of tbody. See pull #814. Thanks prijutme4ty!
- Docs
- Specify pager's
pageSet
method requires a one-based index value. - Miscellaneous corrections & fixes. Thanks prijutme4ty!
- Remove
uitheme
widget option (it was removed in v2.14.0, but not properly documented). Pertinent information on how to modify the uitheme widget class names was moved to the coretheme
documentation. - Add a new pager variables section which contains some useful variables within the pager object (
table.config.pager
). - Update "jQuery data" demo to show the difference between setting a data-attribute and jQuery data directly.
- Add api documentation for using the
getColumnData
function.
- Specify pager's
- Parsers
- Add countdown parser (hh:mm:ss) - demo included with the duration parser.
- Update input-select parser to use the
resort
option.
- Widgets (general)
- Build widget & storage extension: Pass
"null"
to$.parseJSON
as a fallback. Fixes issue #586. - Update
remove
widget function for columnSelector, cssStickyHeaders, math, pager, repeatHeaders, saveSort & stickyHeaders. - Widgets removed from beta: alignChar, columnSelector, math, output, print, reflow & staticRow.
- Build widget & storage extension: Pass
- AlignChar:
- Don't add align character when no content is right of it. Prevents adding a hanging decimal, e.g.
3000.
.
- Don't add align character when no content is right of it. Prevents adding a hanging decimal, e.g.
- Chart widget (New; beta):
- Generic chart widget used to basically extract data from the table and output in multiple formats.
- Current chart libraries supported: Google charts, Highcharts & FusionCharts.
- Some additional processing may be required to add extra variables (graph colors, labels, etc).
- A demo is available here.
- An example of this widget is also available here.
- Thanks to TheSin- for creating this widget!
- ColumnSelector:
- Fix column index issue, again.
- The
refreshColumnSelector
method has been updated to accept a parameter (get more details):- If an array of zero-based column indexes is passed by this method, "auto" mode will be disabled & only columns within the array will be shown - critical or disabled columns will always be shown.
- If a non-array is passed by this method, the "auto" mode will be enabled.
- Fixes issue #798.
- A change in "auto" checkbox now triggers a "columnUpdate" event.
- Dragtable (New; beta)
-
The dragtable jQuery UI widget adds column reordering to a table.
-
This isn't a tablesorter widget, but a modification made to a jQuery UI widget to better integrate with tablesorter - demo.
-
A modified version of dragtable has been included in the "extras" folder; this is a jQuery UI widget, not a tablesorter widget!
$(function () { $('table') .dragtable({ dragHandle: '.table-handle', excludeFooter: true }) .tablesorter({ theme: 'blue', selectorSort: '.sort', widgets: ['zebra', 'filter'] }); });
-
This modified version, so far, allows column reordering to work with the filter & resizable widgets.
-
Additional work will be required to get this jQuery UI widget to work with the scroller, columnSelector & stickyHeaders widgets.
-
- Editable
- Update to add a
editable_columnsArray
which is created from theeditable_columns
option. Wheneditable_columns
contains a string (e.g.0-3
), this option will contain an array of zero-based column indexes. - The dragtable mod widget can then use this option to rearrange and maintain editable columns properly.
- Update to add a
- Filter
- Hide filter row using the
filtered
class name (table.config.widgetOptions.filter_filteredRow
). - Select source, and unparsed filter text now priorities data from the
textAttribute
. Fixes issues with Formatter widget - see issue #812. - Update select2 filterFormatter code to properly escape regexp characters. Fixes issue #796.
- Normalize
table
parameter for public functions.
- Hide filter row using the
- Formatter (New; beta)
- This new widget allows you to apply formatting to the columns (demo).
- Fixes issue #812.
- Output
- Fix trim spaces for header cells.
- Pager
pageReset
now used while filtering. See issue #778.- Get most up-to-date filter before setting
pageReset
. Fixes issue #783. filteredRows
now properly calculated when firsttbody
is set with acssInfoBlock
class name`.- Page size resets to original page setting instead of always 10.
- Add
pageAndSize
method to set both the page & size. - Add
pagerUpdate
method to force a pager update; even if no ajax parameters have changed. Fixes issue #801. - Add
cachedIndex
variable which is useful if you need to find the currently visible rows within the pager in the internal cache (table.config.cache
). See the documentation for an example. - Update goto selector independently of other elements. Fixes issue #811.
- Modified to apply widgets & fire "pagerComplete" after the cache is built; this specifically applies to ajax tables.
- Print
- Ignore columnSelector "auto" setting when
columnSelector_mediaquery
option is disabled (false
). Fixes issue #808.
- Ignore columnSelector "auto" setting when
- Reflow
- Trim stored header text.
- Scroller
- UITheme
- Now updates properly when dynamically changing the
table.config.theme
option. - During an update, add inner wrapper to specific columns that are missing it.
- Add separate sort class names to both the header & icon element; breaks old demos, but falls in-line with the addition of core css icon class settings in v2.18.3.
- Now updates properly when dynamically changing the
- Themes
- Add filter row background color; it appears that Chrome uses the
<tr>
background color when thehideme
class is added to the row. - Updated Bootstrap to 3.3.2.
- Add filter row background color; it appears that Chrome uses the
- Testing
- Update QUnit.
- Remove jsHint checks.