An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

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')