Make All Wiki Tables Sortable Macro

Last modified by Paul Walker on 2017/10/18 10:33

cogMakes all wiki tables on the page it is inserted sortable (and optionally filterable)
TypeXAR
CategoryMacro
Developed by

Clemens Robbenhaar

Rating
Rate!
2 Votes
LicenseGNU Lesser General Public License 2.1
Installable with the Extension Manager

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:

before-sortable.png

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, or both:

macro-settings.png

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:

after-sortable.png

or even be filtered, if you typed in "yes" in the "Filterable" settings:

after-sortable-filerable.png

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:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki
Tags:
Created by Clemens Robbenhaar on 2015/12/05 19:04
    

Get Connected