Item5568: ActionTracker enhancement: sortable columns
Priority: Enhancement
Current State: No Action Required
Released In:
Target Release: n/a
*Sortable columns*: "action tracker generates HTML tables, not TWiki tables, so the tables are not sortable by TablesPlugin." (
TWiki:Main.CrawfordCurrie - 22 Feb 2007). Understood. But users, after they get used that feature, expect to see it everywhere.
I have a work-around that can be used in implementation. Obviously it would be better if a solution was native in the plug-in, because this requires extra effort and perhaps some knowledge of HTML. One option: there are "Javascript table sorters to avoid the round-trip to the server." (
TWiki:Main.CrawfordCurrie - 26 Apr 2008).
Here's the work-around:
- For the column headers that you are using, add your own hyperlink to set a URL parameter with the desired sort order, e.g.,:
* Set ACTIONTRACKERPLUGIN_TABLEHEADER = |<a style="color:white;" href=%SCRIPTURL%/view/%WEB%/%TOPIC%?action_sort=$due>Due date</a>|<a style="color:white;" href=%SCRIPTURL%/view/%WEB%/%TOPIC%?action_sort=$text>Description</a>|<a style="color:white;" href=%SCRIPTURL%/view/%WEB%/%TOPIC%?action_sort=$uid>(edit)</a>|
- Detect that parameter and assign it to a TWikiVariable (usually the default order is
$due
, but here it's changed to $uid
). * Set ACTIONTRACKERPLUGIN_SORTORDER = %IF{"defined action_sort" then="%URLPARAM{action_sort}%" else="$uid"}%
- Use the sort order:
%ACTIONSEARCH{state="open" topic="%TOPIC%.*" sort="%ACTIONTRACKERPLUGIN_SORTORDER%"}%
Notes:
- Step 1 should be done in the topic with the ACTIONSEARCH rather than defined globally. Otherwise all such column headers would show hyperlinks, but they only work if steps 2 and 3 are also done in the topic. In that case, Step 1 should be hidden in HTML comment tags.
- Step 2 must be done in the topic with the ACTIONSEARCH. It should be hidden in HTML comment tags.
- Steps 2 and 3 may be combined in one line.
- If the topic contains more than one ACTIONSEARCH, as written, the same sort order is imposed on them all. You could use different parameters for each table if needed.
Aside: the work-around would be easier to roll-out if header formatting (
Item4312) was implemented.
--
TWiki:Main/SeanCMorgan - 27 Apr 2008
P.S. Crawford, thanks for the suggestion to add enhancement requests here. I thought this web was just for ... you know ... Bugs!
Since I added support for format, header, footer etc parameters it's easy to generate a result that is sortable using the
TablePlugin.
So no action required here.
--
CrawfordCurrie - 29 Jan 2009