Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/stuartlangridge/sorttable

JavaScript client-side sortable tables
https://github.com/stuartlangridge/sorttable

Last synced: 3 months ago
JSON representation

JavaScript client-side sortable tables

Awesome Lists containing this project

README

        

JavaScript client-side sortable tables

See http://www.kryogenix.org/code/browser/sorttable/ for details and FAQ.

If you just want sorttable.js itself, it's in the `sorttable/` folder.

Running the tests:
grunt test

To get the test dependencies, `npm install`.

To add new tests, edit tests/test-definitions.json and add a new item to the top-level "tests" var. For example,

"basic": {
"rows": [
["1", "dog", "Adam"],
["2", "apple", "Charles"],
["3", "banana", "Bill"],
["4", "cat", "David"]
],
"expected_column_1_after_sort_by_column_n": [
["1", "2", "3", "4"],
["2", "3", "4", "1"],
["1", "3", "2", "4"]
]
}

This defines (in "rows") a table with four rows and three columns. In "expected_column_1_after_sort_by_column_n" is then defined one tuple for each column; a tuple shows the contents of column 1, in order.

So, the above example has three tuples in it, one for each column. The second tuple, ["2", "3", "4", "1"], is saying that after sorting the table by the second column, we should see the *first* column containing the values "2", "3", "4", and "1", in that order.

It is advisable to make the first column of all test tables be the integers, because it makes things easier to understand, but it's not compulsory.