https://github.com/rdmurphy/tablesift.js
Sorting HTML tables quickly.
https://github.com/rdmurphy/tablesift.js
Last synced: about 1 year ago
JSON representation
Sorting HTML tables quickly.
- Host: GitHub
- URL: https://github.com/rdmurphy/tablesift.js
- Owner: rdmurphy
- Created: 2013-08-27T22:52:59.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-08-28T21:09:51.000Z (almost 12 years ago)
- Last Synced: 2025-04-07T17:54:45.618Z (about 1 year ago)
- Language: JavaScript
- Size: 279 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
TableSift
=========
Let's get this party started.

How to Use
----------
```js
TableSift.init( (str) -or- (HTMLTableElement), (object));
```
**Default options**
```js
{
classAsc: 'sift-asc', // class applied to columns sorted ascending
classDes: 'sift-des', // class applied to columns sorted descending
customSort: {}, // custom functions to parse a column's cells, none by default
noSort: [], // don't active a sort feature on provided column indexes, none by default
removeChars: [',', '$'] // ignore these characters when determining value for sort
}
```
**Different class names for sorted columns**
```js
{
classAsc: 'sorted-a',
classDes: 'sorted-d'
}
```
**Custom sorter for column index 2, parses number from a cell's text content**
```js
{
customSort: {
2: function(con, el) { // 'con' == the cell's text, 'el' == the actual cell element
return +con.match(/\d+/)[0]; // regex to find number in string, pull it out, and convert to number
}
}
}
```
**Don't enable sorting for column index 3**
```js
{
noSort: [3] // can take comma-delimited entry
}
```
**removeChars**
```js
{
removeChars: [',', '£'] // comma-delimited characters to ignore; for example, pounds instead of dollars
}
```