https://github.com/christianbach/tablesorter
Flexible client-side table sorting
https://github.com/christianbach/tablesorter
Last synced: 4 months ago
JSON representation
Flexible client-side table sorting
- Host: GitHub
- URL: https://github.com/christianbach/tablesorter
- Owner: christianbach
- License: mit
- Created: 2014-05-20T06:09:41.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2020-03-30T04:56:42.000Z (over 6 years ago)
- Last Synced: 2026-01-31T10:48:35.649Z (5 months ago)
- Language: JavaScript
- Size: 769 KB
- Stars: 1,024
- Watchers: 52
- Forks: 488
- Open Issues: 106
-
Metadata Files:
- Readme: README.md
- Changelog: changelog
- License: LICENSE
Awesome Lists containing this project
- awesome-grid - Tablesorter - Small table plugin that enables sorting and several features. Mainly used to enable fast sorting on html table. (Specific Libraries / jQuery)
README
tablesorter
===========
### Flexible client-side table sorting
#### Getting started
To use the tablesorter plugin, include the jQuery library and the tablesorter plugin inside the head-tag of your HTML document:
```html
```
Tablesorter works on all standard HTML tables. You must include THEAD and TBODY tags:
```html
Last Name
First Name
Email
Due
Web Site
Smith
John
jsmith@gmail.com
$50.00
http://www.jsmith.com
Bach
Frank
fbach@yahoo.com
$50.00
http://www.frank.com
Doe
Jason
jdoe@hotmail.com
$100.00
http://www.jdoe.com
Conway
Tim
tconway@earthlink.net
$50.00
http://www.timconway.com
```
Start by telling tablesorter to sort your table when the document is loaded:
```javascript
$(document).ready(function()
{
$("#myTable").tablesorter();
}
);
```
Click on the headers and you'll see that your table is now sortable! You can also pass in configuration options when you initialize the table. This tells tablesorter to sort on the first and second column in ascending order.
```javascript
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
```
For DateTime columns you can specify your format, like this:
```javascript
$(document).ready(function()
{
$("#myTable").tablesorter( {dateFormat: 'pt'} );
}
);
```
The available ones (currently) are: us, pt and uk. (for pt you can use 'dd/MM/yyyy hh:mm:ss')