Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tristen/tablesort
:arrow_up_down: A small tablesorter in plain JavaScript
https://github.com/tristen/tablesort
javascript tablesort
Last synced: 1 day ago
JSON representation
:arrow_up_down: A small tablesorter in plain JavaScript
- Host: GitHub
- URL: https://github.com/tristen/tablesort
- Owner: tristen
- License: mit
- Created: 2012-03-01T05:38:56.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2024-09-17T10:03:26.000Z (3 months ago)
- Last Synced: 2024-10-29T15:35:20.367Z (about 2 months ago)
- Topics: javascript, tablesort
- Language: JavaScript
- Homepage: https://tristen.ca/tablesort/demo/
- Size: 663 KB
- Stars: 1,097
- Watchers: 35
- Forks: 179
- Open Issues: 53
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
tablesort
---A small & simple sorting component for tables written in JavaScript
[![Build Status](https://app.travis-ci.com/tripu/tablesort.svg?branch=master)](https://app.travis-ci.com/tripu/tablesort)
[![npm version](http://img.shields.io/npm/v/tablesort.svg)](https://npmjs.org/package/tablesort)### Quick start
Download the ZIP of this repository or install via command line:
``` cli
npm i tablesort
# Or if you're using Yarn
yarn add tablesort
`````` html
new Tablesort(document.getElementById('table-id'));
```
**[See usage and demos for more](http://tristen.ca/tablesort/demo/)**---
### Browser Support
| | | | | |
|:---:|:---:|:---:|:---:|:---:|
| 8+ ✔ | 3.6+ ✔ | 10+ ✔ | 11.50+ ✔ | 5.1+ ✔ |### Node/Browserify
``` js
// npm install tablesort
var tablesort = require('tablesort');tablesort(el, options);
```### Default CSS
Add the styling from [tablesort.css](tablesort.css) file to your CSS or roll with your own.### Extending Tablesort
If you require a sort operation that does not exist
in the [sorts](https://github.com/tristen/tablesort/tree/gh-pages/src/sorts/)
directory, you can add your own.``` js
Tablesort.extend('name', function(item) {// Regular expression to test against.
// `item` is a table value to evaluate.
return /foo/.test(item);
}, function(a, b) {// Custom sort functionality goes here.
// e.g var n = (a > b) ? -1 : 1;
return n;
});
```If you've made an extend function that others would benefit from pull requests
are gladly accepted!### Contributing
Dependencies: Node.js 16 or 18; npm 8.
Tablesort relies on [Grunt](http://gruntjs.com) as its build tool. Simply run
`npm run build` to package code from any contributions you make to `src/tablesort.js`
before submitting pull requests.Tests are run via:
```sh
npm ci && npm t
```### Licence
MIT
### Bugs?
[Create an issue](https://github.com/tristen/tablesort/issues)