Feature #1718

Table column sorting

Added by Ronie Henrich almost 13 years ago. Updated 3 months ago.

Status:ClosedStart date:2008-07-30
Priority:NormalDue date:
Assignee:Go MAEDA% Done:


Category:Text formatting
Target version:4.2.0


  • Suggestion / Request:
    • It would be great to have some table column sorting features on redmine Wiki.
  • At a glance…
    • Plays nicely with the JavaScript global namespace (the script creates and reuses only one JavaScript object);
    • Multiple columns can be sorted at once by pressing Shift while selecting the columns using either the keyboard or mouse;
    • The new script sorts (on average – based on my very non-scientific calculations), 5 times faster than its predecessor;
    • The plug-in architecture makes writing custom sort functions a breeze;
    • The script can highlight both alternate rows and full columns on a table by table basis;
    • Like its predecessor, the script is fully keyboard accessible;
    • The script can correctly determine a columns datatype should a datatype not be explicitly defined (datatypes determined are limited to numbers, text, currency values and dates);
    • The script is smart enough not to sort columns containing identical data
    • Sort routines can be initiated using JavaScript;
    • Tables can be automatically sorted on a column (or columns) of your choice, even in reverse order;
    • Before-sort and after-sort callback functions (or Object.methods) can be defined for individual tables.
  • Row and column highlighting:
    • The script enables both row and column highlighting.
  • Zebra striping the table rows:
    • Should the table be given the class rowstyle-something, each alternate table row is given the class something after the table has been sorted i.e giving the table a class of rowstyle-alternate will tell the script to give each alternate row the class alternate.
  • Highlighting the currently sorted column:
    • Should the table be given the class of colstyle-something, each TD node within the sorted column is given the class something after the table has been sorted i.e giving the table the class colstyle-alternate will tell the script to give each TD node within the sorted column the class alternate.
  • Making any column sortable:
    • To make any table column sortable, just give the associated table header (TH) tag the class sortable, the script will automatically determine the column datatype, make the entire table header clickable (and not just the text contained within) and create the appropriate up/down arrow within the header when clicked (using the ↑ & ↓ characters).
  • Forcing a columns sort algorithm:
    • Should a column contain a mix of datatypes (or should you know the column datatype), it is advised that you explicitly set the sort algorithm by adding one of the following classNames to the associated table header (TH) tag: sortable-numeric, sortable-currency, sortable-text , sortable-date, sortable-date-dmy or sortable-keep (which keeps the row in it’s original order).
  • Sorting multiple columns:
    • The script can now sort multiple columns. Just hold down the Shift key while selecting the columns to sort (either with the keyboard or with the mouse).

wiki-table-column-sorting.patch Magnifier (7.35 KB) Takenori TAKAKI, 2020-02-17 07:52

wiki-table-column-sorting.patch Magnifier (7.31 KB) Kevin Fischer, 2020-02-19 11:14

0001-Support-table-column-sorting.patch Magnifier (9.21 KB) Go MAEDA, 2020-06-21 16:32

0001-Support-table-column-sorting.patch Magnifier (8.52 KB) Go MAEDA, 2020-06-23 09:37

table-header-before.png (7.19 KB) Go MAEDA, 2020-06-23 09:44

table-header-after.png (7.19 KB) Go MAEDA, 2020-06-23 09:44

Related issues

Related to Redmine - Feature #11543: Sort attachments by name New

Associated revisions

Revision 19833
Added by Go MAEDA 12 months ago

Table column sorting (#1718).

Patch by Takenori TAKAKI.


#1 Updated by Thomas Lecavelier almost 13 years ago

  • Target version deleted (0.8)

The target version field has to be set when it will actually part of the target release.

#2 Updated by Anton Dollmaier over 12 years ago


as this feature is part of wikipedia, it would be nice to get this into redmine-wiki, too.

e.g. I got a table with serverIDs, hostnames and row-numbers, would be nice to re-sort the data dynamically.

#3 Updated by Terence Mill over 10 years ago

+1 Don't forget this one!

#5 Updated by Hrobky Hrobky about 8 years ago

It was not working on my 2.1.4.stable.10880. Maybe the plugin is missing some installation script or there is a change in plugin structure since 2.x.


cd /opt/redmine-2.1/public/plugin_assets
ln -s ../../plugins/redmine_sortable_table-master/assets/ sortable_table

Operator '%' seems to be overridden to do HTML escaping, so do the concatenation in other flavor:


*** 15,22 ****
    macro :sortable_table do |obj, args|
      content_for :header_tags do
-       "  %s\n  %s" % [
-         javascript_include_tag( "tablesort.js", :plugin => 'sortable_table'),
+       javascript_include_tag( "tablesort.js", :plugin => 'sortable_table') + "\n" +
          stylesheet_link_tag( :default, :plugin => 'sortable_table')
-       ]

#7 Updated by Denis Sidorov over 4 years ago

Serg Astra wrote:

Check this https://github.com/AstraSerg/redmine_sortable_table

Does it support Markdown tables?

#8 Updated by Plastik Schnitzer almost 2 years ago

Are there any plans to include this feature to stock redmine? It would be highly appreciate to have a table sorting function in wikis and tickes like its possible on wikipedia for example.

#9 Updated by Takenori TAKAKI over 1 year ago

I made a patch to sort the table elements under 'div.wiki'.
To implement the patch, I used a pure JS library called 'tablesort'.

In Textile format, Specifying the 'th' element in the first row, It makes that column sortable.
In Markdown format, The first row automatically becomes the 'th' element, so all columns are sortable.

#10 Updated by Go MAEDA over 1 year ago

  • Target version set to Candidate for next major release

Although there is a limitation that numbers are treated as strings when sorting, the feature is useful.

#11 Updated by Kevin Fischer over 1 year ago

There was a little problem with the patch (or was it just on my side?): It assumed that the JavaScript/CSS files were already there and thus could not be applied directly. I fixed that.

I tried the patch and function-wise it looked good to me.

Maybe little adjustments are necessary to make it fit better into Redmine's design, but I don't really feel qualified to make any calls on that, so maybe someone else can look into that?

Also: If a new library is included, are there any credits that need to be adjusted anywhere?

#12 Updated by Go MAEDA about 1 year ago

#13 Updated by Go MAEDA 12 months ago

Go MAEDA wrote:

Although there is a limitation that numbers are treated as strings when sorting, the feature is useful.

I have updated the patch to be applicable to the trunk r19831. In addition, updated tablesort to 5.2.1 and added tablesort.number.min.js to sort numeric columns correctly.

#14 Updated by Go MAEDA 12 months ago

  • Subject changed from Wiki - Table column sorting to Table column sorting
  • Category changed from Wiki to Text formatting

#15 Updated by Go MAEDA 12 months ago

Update the patch to fix a small UI issue that the text in a table header is not exactly centered when the column is not sorted. In the screenshots below, "A" is shown slightly to the left, not centered.



#16 Updated by Go MAEDA 12 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for your contribution.

#17 Updated by Mischa The Evil 12 months ago

I actually think it is questionable whether or not this feature should be implemented within the Redmine core in this manner. Some considerations:
  • Given the wealth of JS-implementations, and the (potential) cost of adding/bundling yet another static JS-asset, it might be better to keep this a plugin feature in the first place.
  • What's the rationale for choosing this specific JS-library anyway?
  • Do we actually want to add sorting to all tables (for Textile: with a table header) by default or do we want users to have (more) control over this?
  • Does the current implementation play nice with custom formatters provided by plugins?
  • Given that the sorting is added by default (as it is currently): what's the rationale to integrate specifically this set of supported sort types? I think that we can expect additional feature requests to add support for other sorting types (especially thinking about dates, version numbers, IP addresses, file listings with file size columns)
  • How does the current implementation affect exports? Is it included in the export? Is any sorting in the export marked somehow?

#18 Updated by Go MAEDA 12 months ago

  • Status changed from Closed to Reopened

#19 Updated by Go MAEDA 3 months ago

  • Status changed from Reopened to Closed

Also available in: Atom PDF