This is an old revision of the document!
Table of Contents
sortablejs Plugin
Compatible with DokuWiki
- 2025-05-14 "Librarian" unknown
- 2024-02-06 "Kaos" unknown
- 2023-04-04 "Jack Jackrum" yes
- 2022-07-31 "Igor" yes
Similar to datatables, tablelayout
Needed for linkmanager
Description
A JavaScript-based (client-side) plugin, which can be used to create sortable tables. It is optional for linkmanager plugin.
For server-side sorting or more robust sort facilities use Sam Wilson's sorter, based on https://github.com/Mottie/tablesorter (supports server-side sorting): https://github.com/samwilson/dokuwiki_sortablejs
Previously maintained by oiv (Otto Vainio at otto@valjakko.net)
Usage
After installing the plugin you should make sure that your DokuWiki cache is updated. This can easily be done by changing any parameter value in settings (or by doing a touch conf/local.php).
You need to set <sortable> and </sortable> tags around your table.
<sortable> ^ Col1 ^ Col3 ^ Col3 ^ | 1 | one |02/25/2008 | | 2 | two |02/14/2008 | </sortable>
Table initially sorted by column 1
<sortable 1> ^ Col1 ^ Col3 ^ Col3 ^ | 1 | one |02/25/2008 | | 2 | two |02/14/2008 | </sortable>
Table initially reverse sorted by column 1
<sortable r1> ^ Col1 ^ Col3 ^ Col3 ^ | 1 | one |2008-02-25 | | 2 | two |2008-02-14 | </sortable>
To sort the columns you (the page viewer) just needs to click on the correct column on the first row. A second click on the same column reverses sort.
Date type is sorted, e.g. when US american date format mm/dd/yyyy is used. Of course the format yyyy-mm-dd will always be sorted correctly (no need to label this as date).
Options
<sortable [[r]column] [sumrow[=2]] [column=alpha|numeric|date|nosort] [3phase]>
<sortable r1 sumrow=2 3phase 1=numeric 2=alpha 3=nosort>
││ │ │ │ │ │
││ │ │ │ │ └ No sort option for column 3
││ │ │ │ └ Sort column 2 as text always
││ │ │ └ Sort column 1 as numeric always
││ │ └ Add a 3-phase sort option. Normal, Reverse and Back to original order.
││ └ Prevent last 2 rows from sort. The number can be omitted. Default is last row (=1)
│└ Initially sort by column 1 on page load
└ Reverse initial sort
Misc links
- Historical versions: https://github.com/FyiurAmron/sortablejs/wiki/older-versions
- GitHub revision history: https://github.com/FyiurAmron/sortablejs/commits/master
- Historical bugs/ehnancements: https://github.com/FyiurAmron/sortablejs/wiki/old-issues-and-enhancement-requests
- current issue tracker: https://github.com/FyiurAmron/sortablejs/issues

