Make Tables Sortable Macro
Makes all wiki tables on the page it is inserted sortable (and optionally filterable) |
Type | XAR |
Category | Macro |
Developed by | |
Active Installs | 26 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
As explained in the Syntax Help wiki tables can be made sortable by adding some CSS classes via wiki markup notation like (% class="grid sortable filterable doOddEven" id="some-table-id" %) (and including the proper JavaScript resources via a velocity macro). See also the Table Sorter page.
This is however quite cumbersome for users only comfortable with the WYSIWYG editor.
Instead this extension defines a macro that, if inserted on a given page, does the necessary steps automatically for all tables on the page. The tables still should have a header as the first row, or the results will be quite odd.
Note: so far this extension has only been tested with Firefox & Chrome. Because it is completely JavaScript based, there might be browser incompatibilities.
Usage
First you have some plain tables on the page, where the first row is the heading:
To make them sortable, edit the page in the editor, and insert the "Sorteable Tables" macro. (Sorry for the typo in the name.) You can edit if you want the tables on the page to be sortable, filterable, have a sticky header, or all of them:
Note that the change is not visible directly in the editor (actually a good thing, as it would infere with editing the table headers).
After saving you can see the tables on the page can be sorted by clicking on the headers:
or even be filtered, if you typed in "yes" in the "Filterable" settings:
Disabling Sort for some tables
XWiki 1.1+ If you add a CSS class which contains nosort in the name this disables the sort feature for the table.
Admittedly this means to go to the source editor and add a (% class="nosort" %) on a line above of the table, which defeats a bit the purpose of this macro, but this is how it possible if needed.
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:
- Log in the wiki with a user having Administration rights
- Go to the Administration page and select the Import category
- Follow the on-screen instructions to upload the downloaded XAR
- Click on the uploaded XAR and follow the instructions
- You'll also need to install all dependent Extensions that are not already installed in your wiki
Release Notes
v1.1
v1.0
v0.3
Added parameter to make the table header sticky.
v0.2
Bugfix: Tables were not filterable if a live-table was present on the same page.
v0.1
Initial Version
Dependencies
Dependencies for this extension (org.xwiki.contrib:macro-sortabletables 1.1):
- org.xwiki.platform:xwiki-platform-rendering-wikimacro-api 9.11.4
- org.xwiki.platform:xwiki-platform-skin-skinx 9.11.4
- org.xwiki.platform:xwiki-platform-rendering-macro-velocity 9.11.4
- org.xwiki.rendering:xwiki-rendering-macro-html 9.11.4