create new tag
, view all tags

Older TablePlugin Dev Discussions

These are older TablePluginDev Discussions.

-- PeterThoeny - 13 Aug 2002

Column Sorting Using Javascript

Being able to sort by clicking on the columns is extremely useful. Thank you very much.

Now comes the Feature Request can this be done with javascript? It kinda sucks having to go back to the server to fetch a new page when you already have all the data sitting in front of you. Of course there should be a fallback so that if a user has javascript disabled the server is asked to sort instead of the browser.

http://www.mattkruse.com/javascript/sorttable/documentation.html - has some javascript code for the sorting part. I couldn't find anything for the fallback part.

-- MattWilkie - 12 Jun 2003

An early version of the code did do this, but not everyone has Javascript enabled and it's tough to get the full behavour that is now in the plugin. However, it would certainly be possible to detect Javascript is present (e.g. change the sort link using Javascript in the on page load property. So possible if someone has some hours to spare.

-- JohnTalintyre - 17 Jun 2003

A tip on how to implement Javascript sorting:

<a href="url called to sort" onclick="sortTable(); return false;">column header</a>

This way, the sortTable() method will be called if Javascript is enabled (could be inline Javascript as well) and by returning false, the href won't be fetched. If Javascript is disabled, the link acts just like a normal link thus providing the same behaviour as the current table sorting implementation.

-- ThomasJachmann - 18 Jul 2003

ThomasJachmann is correct; His HTML fragment will use a javascript function if javascript is enabled and execute a GET round-trip to the server if it is not. But, Javascript doesn't have a built-in sortTable() method. However, there are quite a few opensource implementations to sort a table at the browser via javascript. A quick search of Google turns up a few implementations close to what might be needed in this case.

-- TomKagan - 18 Jul 2003

Just a hint...
While the sortable tables are really nice, it's really slow to actually use them. Especially, if tables result from a %SEARCH. At http://www.kryogenix.org/code/browser/sorttable/ I saw a JS library, which would allow sorting on the client side -- really fast! Anybody any guess on the implementation effort?

-- PeterKlausner - 17 Jun 2004

I went and looked at the JS library. Wow it's fast. That would be a great improvement for subsequent sorts.

Here is the trick I failed to mention. I am not using the sort functionality after the table is retrieved. I only want to be able to sort the data for it's initial display. I wonder if there would be a way to add the initial sort into the SEARCH variable. Maybe add a special character to the format="..." section or add a new section sort="col1".

Since we are using the TABLE variable we are also taking advantage of the format functionality but that is not required.

-- KenKoftan - 17 Jun 2004

The original plugin did actually use Java Script. But, switched to server side for wider client support and also because we need things like auto type detection - although server could always feed this information to client. Best solution would probably be to use JavaScript if present, otherwise use server side.

-- JohnTalintyre - 22 Jun 2004

Bug Fixes

Bug with mail notification

Bug: enabling the plugin make mail notification fail

Status: Proposal

Fix: after line 72 in TablePlugin.pm (containing my $cgi = ), add the 4 lines

    # if we are called via mailnotify, abort
    if ( ! $cgi ) { 
      return 0; 
I am not a perl expert, feel free to correct

-- ColasNahaboo - 23 Oct 2001

Windows-only font used

Bug: upchar, downchar, diamondchar uses a font only available on some platforms (Windows)

Fix: use images. We could also use some ascii art, but I could no find any good enough

  1. Add the 3 gif files attached to the distrib (unzip in TWiki dir)
  2. replace the 3 lines at line 100 in lib/TWiki/Plugins/TablePlugin.pm :
    $upchar = "&#9650;"; 
    $downchar = "&#9660;"; 
    $diamondchar = "&#9674;"; 
by the 4 lines:
    my $pubUrlPath = &TWiki::getPubUrlPath(); 
    $downchar = "<img src='$pubUrlPath/icn/char_up.gif' width='10' height='12' />"; 
    $upchar = "<img src='$pubUrlPath/icn/char_down.gif' width='10' height='12' />";  
    $diamondchar = "img src='$pubUrlPath/icn/char_diamond.gif' width='10' height='12' />"; 

Note: I also reversed the up and down arrow to be consistent with the way they are used in other toolkits.

-- ColasNahaboo - 30 Oct 2001

Table Plugin Swaps Padding and Spacing

You guys did this on purpose to drive us nuts didn't you....

there's a bug in this code:

sub emitTable
    my $direction = $up ? 0 : 1;
    my $doIt = doIt( $curTable[0] );
    my $text = "$currTablePre<table border=\"$tableBorder\" "
             . "cellspacing=\"$cellPadding\" cellpadding=\"$cellSpacing\">\n";

Can you see what it is?

."cellspacing=\"$cellPadding\" cellpadding=\"$cellSpacing\">\n";

Padding and Spacing are swapped smile

-- AndrewTetlaw - 11 Feb 2002

BUG - This Plugin is incompatible with PatternsSkin

If you use the directive

  %TABLE{ ... tablewidth="100%" ...}%

with the PatternSkin skin the table will NOT expand to the width of the window.

This is because the skin uses CSS and there is a directive there

.twikiTopic table {

table width=100% will not override a style (see http://www.hwg.org/resources/faqs/cssFAQ.html#precedence).

To override a style locally you would have to write

    <table style="width: 100%">

This plugin needs to be updated to generate directives in this format so as to be comaptible with CSS.

I understand that as a temporary measure the 'auto' has been commented out.
However the same principle applies to the other directives that are generated by this and similar plugins.

-- AntonAylward - 26 Jun 2005

BUG - Table Sorting Messed Up

When a table contains vertical spans in TML, sorting causes all kind of havoc... see bug report and test case at TableSortingMessedUp.

-- ThomasWeigert - 11 Aug 2005

BUG - Sorting multiple tables

It seems like the fix for sorting multiple tables was never included in the official release: Support.TablePluginSortMultipleTable

Is it possible to do so for a new version?

-- PieterVanDerSpek - 07 Oct 2005

I have hacked TablePlugin to provide CSV Export capability. I don't think that the way I've implemented it is particularly nice, but it's an important requirement in our organisation and quick-and-dirty was the only answer.

  1. Add new parameter %TABLE{... exportcsv="on" ...}%.
  2. While parsing the table data for HTML, also parse for CSV (emitTable())
  3. Save CSV data in pub/Web/Topic/_tableX.csv where X is the tableCount -- each table gets a unique file (emitTable())
  4. Add link to the CSV attachment to the return text for rendering (emitTable())

The link text and position is hard coded -- could easily be retrieved from Plugin settings.

  • csv-patch: Patch to Export table as CSV. Based on v1.013 01 Aug 2004

-- MagnusLewisSmith - 19 Oct 2005

Thanks Magnus, this is a very useful patch.

-- PeterThoeny - 02 Nov 2005

BUG - Sorting on dates < 1970

I tried sorting on a column that contained dates that contained a year of 1853 and TWiki errored out on me. The fix I implemented was to update Plugins/TablePlugin/Core.pm such that the "use Time::Local" is replaced with "use Time::Local 'timegm_nocheck';" I then replaced the two references to timegm() with timegm_nocheck(). This may mean that Core.pm needs additional checks to verify the range of the months and day of the month that timegm() is now doing that timegm_nocheck() does not do.

-- TaitCyrus - 21 Nov 2005


See also EnhancedTablePluginSorting.

The TablePlugin is very nice. The EnhancedTablePluginSorting plugin is now installed at TWiki.org (TWiki.TablePlugin) with slightly different default colors. (I patched the mailnotify bug).


  • Request: Would be nice to be able to control if the last row should be excluded. This is needed when the last row has some spreadsheet formulas with table summaries.
  • Request: Better to attach arrow images to the plugin topic instead of pub/icn directory. This will avoid "gotchas" when upgrading TWiki.
  • Idea: Would be nice to control other table parameters like table width, border, cellpadding, cellspacing.
  • Problem: How to handle table headings that are already a link. Now links get replaced by the sorting link.
  • Minor detail: The empty line after a table gets "eaten", i.e. a bullet that separated by an empty line is now directly connected to the table.
  • Very minor detail: There is a linked space after link.
  • Question: For what is the diamond symbol used?

-- PeterThoeny - 11 Nov 2001

I have noticed a pair of "glitches" of TablePlugin:

-- AndreaSterbini - 22 Nov 2001

Attached TablePlugin.zip is an updated version of the plugin. I did not upload it to the TablePlugin topic since I didnot want to overwrite John's original version.


  • Added table border, cell spacing & padding
  • Added gif files (extra chars don't display in Netscape)
  • Sort arrow and sort order seemed to be reverse. Down arrow sorts now down.
  • Colas's bug fix of failed mail notification.
  • Did not use EnhancedTablePluginSorting because it has bugs (only first table sorts, non-XHTML code) and syntax that needs some work.

John, should I update the main topic?

-- PeterThoeny - 29 Nov 2001

Attached updated plugin to TablePlugin topic (with John's blessings)

-- PeterThoeny - 02 Dec 2001

Another RFE -- a means to set column width.

-- RandyKramer - 02 Dec 2001

I am getting errors with (last also) TablePlugin installed when I save. This happens when I have both TablePlugin AND SessionPlugin installed.

-- AndreaSterbini - 03 Dec 2001

Now (version of 4 Dec 01) I can save, but I must anyway deactivate the SessionPlugin for some strange reasons ...

-- AndreaSterbini - 03 Dec 2001 (yes, I have a Time Machine!!! wink )

Hello, this is a neat tag - quite useful. On my system I wanted the ability to color rows by the contents of a column (eg, highlight all bugs which belong to me). So I wrote a small extension to TablePlugin (changes to TablePlugin.pm are only a couple dozen lines) which lets one color the cells pretty flexibly.

One example (taken directly from the output)...


%TABLE{tableborder="0" cellpadding="3" cellspacing="1"
headerbg="#AACCCC" databg="#95bFA5,#BCe7A5,#DFffA5,#ffeeee"
cellcoloring="filterbycol:3" bgfilter="high,med,low"}% 
| *Chore* | *Owner* | *Priority* | *Comment* |
| garbage | Mommy | ---| DNA experiment! |
| lawn | Cynthia | medium | "English garden"! |
| bills | Mommy | --- | Knock! Knock! |
| laundry | Papa | medium | Not a nudist camp! |
| garage | Papa | --- | Sale! |
| dishes | Johnny | high | No forks! |
| vacuum | Maggie | low | Asthmosis! |


Chore Owner Priority Comment
garbage Mommy --- DNA experiment!
lawn Cynthia medium "English garden"!
bills Mommy --- Knock! Knock!
laundry Papa medium Not a nudist camp!
garage Papa --- Sale!
dishes Johnny high No forks!
vacuum Maggie low Asthmosis!

I created a seperate topic for more discussion & examples of other colorings: TablePluginColoringExtension.

-- SlavaKozlov - 12 Feb 2002

Header Alignment Breaks Multi-Column Span

(I hope this is the right section to put this under, if it isn't, someone feel free to move it.)

When setting a default header alignment in TablePlugin, multi-column-span stops working.

So for example this:

a b

rendered as:

a b

A fairly minor bug, but it would make the default header alignment variable fairly useless for webs that use a lot of multi-column-span tables.

-- MikeMaurer - 22 Apr '02

Bug fix for sorting on dates

I am running modperl under apache with Redhat linux version 7.0. When I try to sort on a date column, I get a server error. The apache error log reports:

[error] Can't handle date (0, 0, 0, 5, 10, -1899) at  ../lib/TWiki/Plugins/TablePlugin.pm line 143

for a date in the format 05-Nov-01.

It looks like the $year variable isn't being properly expanded in a numeric context. When it is used in the subtraction to timegm, it is the original string version (e.g. 01, 04). If I set $year numerically using 2000 + $year or 1900+$year it works properly. This could be a modperl thing, but it will work for non-modperl so I see no reason not to add it. Also I corrected a single & (bitwise and) to a double & (logical and) and added an explicit test on $year for setting the 2000 + case since 99 would be set to 2099 otherwise.

Can somebody add this to the distributed copy on the TablePlugin page please.

*** TablePlugin.pm~     Thu Dec  6 08:18:11 2001
--- TablePlugin.pm      Thu Dec  6 11:09:57 2001
*** 134,141 ****
          $date = timegm(0, $5, $4, $1, $mon2num{$2}, $3 - 1900);
      } elsif( $text =~ m|^\s*([0-9]{1,2})[-\s/]([A-Z][a-z][a-z])[-\s/]([0-9]{2,
4})\s*$| ) {
          my $year = $3;
!         $year = "19$year" if( length( $year ) == 2 & $year > 90 ); # FIXME do 
based on current year?
!         $year = "20$year" if( length( $year ) == 2 );
          $date = timegm( 0, 0, 0, $1, $mon2num{$2}, $year - 1900 );
      } elsif ( $text =~ /^\s*[0-9]+(\.[0-9]+)?\s*$/ ) {
          $num = $text;
--- 134,141 ----
          $date = timegm(0, $5, $4, $1, $mon2num{$2}, $3 - 1900);
      } elsif( $text =~ m|^\s*([0-9]{1,2})[-\s/]([A-Z][a-z][a-z])[-\s/]([0-9]{2,
4})\s*$| ) {
          my $year = $3;
!         $year = 1900 + $year if( length( $year ) == 2 && $year > 90 ); # FIXME
 do based on current year?
!         $year = 2000 + $year if( length( $year ) == 2 && $year <= 90);
          $date = timegm( 0, 0, 0, $1, $mon2num{$2}, $year - 1900 );
      } elsif ( $text =~ /^\s*[0-9]+(\.[0-9]+)?\s*$/ ) {
          $num = $text;

-- JohnRouillard - 06 Dec 2001

Thanks for reporting. Is fixed, tested and uploaded. Fix:

        $year += 1900 if( length( $year ) == 2 && $year > 80 );
        $year += 2000 if( length( $year ) == 2 );

-- PeterThoeny - 06 Dec 2001

The TablePlugin is great! But I had some problems with sorting columns where some cells are indented and some others not. The following table shows an example.

col1 col2
row1 show
row2 test
row3 show
row4 test

After sorting the second column you can see the 'wrong' sorting. The row2 is sorted before all other rows. I have fixed the problem by removing the leading and trailing blanks in a column before sorting:

--- TablePlugin.pm      2001/12/09 14:03:29     1.1
+++ TablePlugin.pm      2001/12/10 09:07:42
@@ -189,6 +189,9 @@
             $value = $1;
             push @row, [ $value, "$attr", "th" ];
         } else {
+            if( /^\s*(.*)\s*$/ ) {   # strip white spaces
+                $_ = $1;
+            }
             $value = $_;
             push @row, [ $value, "$attr", "td" ];

-- StefanScherer - 10 Dec 2001

Thanks for reporting. Is fixed.

-- PeterThoeny - 05 Jan 2002

Request. Can this plugin be modified such that if databg="none" then cells have no color, rather taking on the color/background of the page the table is on. Unfortunately if 'databg' is not defined on the TWiki page, then the default value is used and there is no way to override this behavior. The following appears to support this functionality.

<                $attr .= " bgcolor=\"" . $dataBg[$rowCount % ($#dataBg + 1) ] . "\"";
>           if ($dataBg[$rowCount % ($#dataBg + 1) ] ne "none") {
>          $attr .= " bgcolor=\"" . $dataBg[$rowCount % ($#dataBg + 1) ] . "\"";
>       }

-- TaitCyrus - 15 Feb 2002

I have fixed the multiple table sorting bug in the EnhancedTablePluginSorting. I have included TablePlugin.pm code with the updates. It is the current 20011201 release of the code.

I have been working on using the TablePlugin code in conjection with the TWikiForms to add and delete elements of a table without actually having to edit the text of the page. I have created a page with the updated files and information (SimpleTableEntryUsingForms).

-- ShawnBradford - 26 Feb 2002

This module rules! But I see in my apache error.log:

Use of uninitialized value in concatenation (.) at ../lib/TWiki/Plugins/TablePlugin.pm line 377.

Line 377 of TablePlugin.pm says:

      return "$currTablePre<nop>";

(I am using Version TablePlugin.pm Version 1.0000, apache 1.3.19, mod_perl and Taintcheck on)

Unfortunately I wasn't able to reproduce this error, so I can't provide you with any table data. Does anybody see this in his error.log?

-- MatthiasWientapper - 07 Mar 2002

Added valign, headeralign and dataalign; fixed bug of swapped cellpadding/cellspacing; fixed warning of uninitialized value.

Slava: Your color coding looks interesting. I donot want to take it into the table plugin because it depends on other libraries and increases the complexity not many people need. However, for those who do it would be good make the table plugin aware of your module, so that you can simply drop in your module. May be you can propose a patch to TablePlugin.pm where the plugin checks at init time if your module is installed.

-- PeterThoeny - 12 Mar 2002

Incorporated ShawnBradford's EnhancedTablePluginSorting feature.

-- PeterThoeny - 13 Mar 2002


From a user's perspective I'd love to be able to reference % Table {MyTableData.csv or MyTableData.xml}% This seems much more natural and easier until a GUI table plugin applet comes of age.


-- DennisDaniels - 21 Mar 2002

Dennis :

It looks like you would like to target code that makes it easier for a person to update and change table information. I have been working on a way to do this using the built in TWikiForms capability. Look at SimpleTableEntryUsingForms, this might be of interest.

-- ShawnBradford - 25 Mar 2002

Yet another variant of editing tables in place is the EditTablePlugin, it can coexist with the TablePlugin.

-- PeterThoeny - 19 Apr 2002

This plug-in was throwing a lot of warnings into my Apache server's error.log. I fixed this by replacing lines 284-286 with

      if (defined($initSort)) {
         $sortCol = $initSort - 1;
         $up = $initDirection;
         $direction = $up ? 0 : 1;

-- GladeDiviney - 19 Apr 2002

This plug-in does not sort the file attachments correctly. You can verify this by going to any of the Test pages and try to sort the attachments. The problem is with all the HTML tags that are added prior to the actual text you see in the browser driving the sorting function. I have been working on a fix since this has been bugging me for a while. Here are my modifications :

Added byText sorting function :

sub byText
   my $B = $b->[$sortCol]->[0];
   my $A = $a->[$sortCol]->[0];
   $B =~ s/(.*)>(.*)<\/a>/$2/; #Strips out all the HTML syntax in the text
   $A =~ s/(.*)>(.*)<\/a>/$2/;
   $B cmp $A;

I replaced the following lines :

if( $up ) {
   @curTable = sort { $b->[$sortCol]->[0] cmp $a->[$sortCol]->[0] } @curTable;
} else {
   @curTable = sort { $a->[$sortCol]->[0] cmp $b->[$sortCol]->[0] } @curTable;

With the following lines :

if( $up ) {
  @curTable = sort byText @curTable;
} else {
  @curTable = reverse sort byText @curTable;

-- ShawnBradford - 30 Apr 2002

Added "none" value to databg parameter, suggested by TaitCyrus, using this code:

>     my $color = "";
<                $attr .= " bgcolor=\"" . $dataBg[$rowCount % ($#dataBg + 1) ] . "\"";
>                my $color = $dataBg[$rowCount % ($#dataBg + 1) ];
>                $attr .= " bgcolor=\"" . $color . "\"" unless( $color =~ /none/i );

Fixed sorting by stripping HTML tags, removing links and making sort ignore case, suggested by ShawnBradford, using this code:

> # =========================
> sub stripHtml
> {
>    my( $text ) = @_;
>    $text =~ s/\&amp;nbsp;/ /go;                     # convert space
>    $text =~ s/\[\[[^\]]+\]\[([^\]]+)\]\]/$1/go; # extract label from [[...][...]] link
>    $text =~ s/<[^>]+>//go;                      # strip HTML
>    $text =~ s/^ *//go;                          # strip leading space space
>    $text = lc( $text );                         # convert to lower case
>    return $text;
> }
<         if( ! $stype ) {
>         if( $stype ) {
<                 @curTable = sort { $b->[$sortCol]->[0] cmp $a->[$sortCol]->[0] } @curTable;
>                 @curTable = sort { $b->[$sortCol]->[$stype] <=> $a->[$sortCol]->[$stype] } @curTable;
<                 @curTable = sort { $a->[$sortCol]->[0] cmp $b->[$sortCol]->[0] } @curTable;
>                 @curTable = sort { $a->[$sortCol]->[$stype] <=> $b->[$sortCol]->[$stype] } @curTable;
<                 @curTable = sort { $b->[$sortCol]->[$stype] <=> $a->[$sortCol]->[$stype] } @curTable;
>                 # efficient way of sorting stripped HTML text
>                 @curTable = map { $_->[0] }
>                             sort { $b->[1] cmp $a->[1] }
>                             map { [ $_, stripHtml( $_->[$sortCol]->[0] ) ] } @curTable;
<                 @curTable = sort { $a->[$sortCol]->[$stype] <=> $b->[$sortCol]->[$stype] } @curTable;
>                 @curTable = map { $_->[0] }
>                             sort { $a->[1] cmp $b->[1] }
>                             map { [ $_, stripHtml( $_->[$sortCol]->[0] ) ] } @curTable;

-- PeterThoeny - 05 Jun 2002

I have got the same 'problem' to disable the default background in the table, but I used following code. Now you can use databg="" to overwrite the value.

<     @dataBg = split( /,\s*/, $tmp ) if( $tmp );
>     @dataBg = split( /,\s*/, $tmp ) if( defined $tmp );

Sorry, this doesn't work, $tmp is always defined frown But that may be a good solution if extractNameValuePair() could return an undefined value.

-- StefanScherer - 05 Jun 2002

MicahHoffman reported apache log errors in in Support.TablePluginSortMultipleTable:

[Wed Jun 19 13:02:12 2002] view: Use of uninitialized value in string eq at ../lib/TWiki/Plugins/TablePlugin.pm line 302.
[Wed Jun 19 13:16:48 2002] view: Use of uninitialized value in subtraction (-) at ../lib/TWiki/Plugins/TablePlugin.pm line 297.

In addition, it is not possible to initially sort multiple tables on a single topic:

Preceeded by TABLE{ initsort="2" } :

Table 1 AAASorted ascending BBB
yyy aaa uuu
aaa bbb aaa
uuu eee lll
www ggg iii

Preceeded by TABLE{ initsort="3" } :

Table 2 AAA BBBSorted ascending
7 6 1
2 16 5
6 4 33
1 10 99

Preceeded by TABLE{ initsort="1" } :

Table 3Sorted ascending AAA BBB
i t s
i r i
k e h
t p s
w e u

Yeep, initsort works only for the first table. Could be fixed. Any takers?

-- PeterThoeny - 24 Jun 2002

Correction described in TablePluginSortMultipleTable.

-- RaymondLutz - 14 Dec 2006

Not to be picky or anything, but one thing that through me for a loop the first time I used the plugin was the typo in the docs. For instance, go to http://twiki.org/cgi-bin/view/Plugins/TablePlugin and look at the right-most column of the third row of the first table. It states initsort="down" when it should be initdirection="down". Kinda confusing until you get the typo.

-- MicahHoffman - 25 Jun 2002

The multiple table init sorting problem has been fixed using the TablePlugin.pm that is supplied for the SimpleTableEntryUsingForms. It contains all the functionality that is in this current version.

I have also included a stripped version here that should sort multiple table correctly on one page. You might want to make sure the direction is correct though.

-- ShawnBradford - 26 Jun 2002

<noautolink> ... </noautolink> should apply inside of tables with TablePlugin is installed, but does not. Observe:

Main.GladeDiviney Not linked, good!
A Table
Main.GladeDiviney Linked! Bad TWiki! No treat!

Similarly, specifying the tags inside of tables doesn't work either:

GladeDiviney Not linked, good!

A Nuther Table
<noautolink> Main.GladeDiviney Aw nuts. </noautolink>

-- GladeDiviney - 26 Jun 2002


Have you tried the <nop> TWiki tag? Look at the table below. Seems to work if you only have a few links.

Main.GladeDiviney Not linked, good!

A Nuther Table
Main.GladeDiviney Not linked, good!

-- MicahHoffman - 27 Jun 2002

Back on 19 April Glade Diviney reported getting errors in his apache error log. Presumibly caused by something around lines 284-286 (that was fixed by the lines he provided). Now what I want to know is what was the error, and does the fix still apply?

I ask as I am getting:

[Sun Jul 21 19:07:23 2002] null: Use of uninitialized value at ../lib/TWiki/Plugins/TablePlugin.pm line 284.
[Sun Jul 21 19:07:23 2002] null: Use of uninitialized value at ../lib/TWiki/Plugins/TablePlugin.pm line 289.
...every time a table is rendered.

Have used the 05 Jun 2002 - 07:05 and 13 Mar 2002 versions of the TablePlugin.zip on my Dec 2001 Release TWiki (FreeBSD 4.6 / Apache/1.3.26 (Unix) mod_perl/1.27 mod_ssl/2.8.10 OpenSSL/0.9.6a).

-- DrewCard - 21 Jul 2002

A simple wokaround for sorting: Use the tidle character in the last row

Who Work
JC 5
SM 4
SC 2
JC 4
~Total: ~ 15

Use ~, ~~, ~~~ etc if you have more then one summary row.

-- PeterThoeny - 03 Aug 2002

The ~ trick doesn't work (here at least). Are you just relying on sort order making it last in the sequence? This is fine - until you order the sort the other way.... Also, I don't think many users are going to like a total of ~123.00, it looks like "approximately" to me. I'm happy to have a go at hacking the code to include the earler requested ignore last (should that be ignore last "N"?) rows feature. I would also like to have a way to have a table like this:

Table Title
col1 col2 col3
a b c
b c a
c a b

allow sorting (ie. skip the table title). I can't see an obvious way to do this automagically but an ignore first param (like the ignore last) would work?

-- DarrylGreen - 05 Aug 2002

It seems that most non-sorting lines are at the top or bottom of tables, and the interior fields are sortable. So how about an option to prevent sorting of lines with cells that are in header format at the beginning or end of tables? So in the following example:

| *Table Title* |||
| *col1*     | *col2* | *col3* | *col 4 *|
| 3          | 1      | 9      |  6      |
| *4*        | 6      | 3      |  8      |
| 9          | 8      | 2      |  9      |
| *Total a:* | ~ %CALC{$SUM($ABOVE())}% ||
| *Total b:* || ~ %CALC{$SUM($ABOVE())}% |

The first two rows wouldn't be sorted, (col1, col2, col3, col4 would be sorting links) The last two rows wouldn't be sorted, but row 4 would be sorted because it has a non-header row above and below it in the original source. The question is what to do if somebody wanted to bold the line starting with 9. By my idea, it wouldn't sort because it is part of a block of lines with bold heading style. I like the idea that the code will just "do the right thing", but maybe this idea isn't really that good. However, I do believe that this functionality should be the default since people don't expect to sort header/footer rows.

Quips, comments, evasions, questions or answers?

-- JohnRouillard - 05 Aug 2002

I haven't spent any time on trying to make the plugin "do the right thing" automagically, partly because I'm not 100 percent sure that a plugin that gives lots of control over formatting is the place to guess formatting from content and partly because I don't need it to work automagically - the places where this is an issue for me are where I'm using %INCLUDE% to bring in a ghastly looking, nested, formatted search plus some calcs - putting explicit table settings in is not a big problem - so long as there is a way to do it.

Anyway, I've attached my hacked version of the plugin here as TablePluginNew.pm. It is currently running on our intranet (which is running a recent alpha to get the other bits I needed...). I have added 2 new parameters:

New Parameters
skipfirst 0 Set this to the number of rows of heading before the row with the per-column headings you want to be able to select to sort the column. Setting it to "1" for this table would make this table sortable
skiplast 0 Set this to the number of rows (eg calculated total row) not to sort at the bottom
A row at the bottom that will stay there if skiplast is set to 1

-- DarrylGreen - 07 Aug 2002

Waay cool on the skipfirst & skiplast. Im going to have to install this tonight and check it out. I hope this makes it into the core ASAP....

-- JohnCavanaugh - 07 Aug 2002

I am getting "uninitialized value" errors from line 297 and line 302 in my httpd error_log. This is with the released plugin in TablePlugin.

-- JonReid - 13 Aug 2002

I'm having some issues with the sorting of dates. The issue is that I don't think the plugin is recognizing the cell contents as a date and is therefore sorting it as text. For instance:

Date - TimeSorted descending
03-Jul-2002 - 09:08
03-Jul-2002 - 07:00
26-Jun-2002 - 14:30
11-Jun-2002 - 08:00
07-Jun-2002 - 10:00
13-Apr-2002 - 11:01
08-Jan-2001 - 21:55

If you sort this based on this field, the TablePlugin should sort it according to date (according to the docs on that page). It doesn't. I'm looking to have a table of actions performed on a computer sorted in chronological order by most recent at the top. According to the docs, this should work. Any ideas?

-- MicahHoffman - 03 Jul 2002

With some reformating of the dates to match the requirements in the documentation (ignoring mistake of YYY rather than YYYY) it works. It's certainly possible to generalise the date formatting a bit more.

Date - TimeSorted descending
03 Jul 2002 - 09:08
03 Jul 2002 - 07:00
26 Jun 2002 - 14:30
11 Jun 2002 - 08:00
07 Jun 2002 - 10:00
13 Apr 2002 - 11:01
08 Jan 2001 - 21:55

-- JohnTalintyre - 03 Jul 2002

You are correct in that it works if you only use spaces for delimeters. However, the docs state you should be able to use "-" or "/" yet if you do, the entire text phrase is treated as text instead of a date. I have modified my table above with the 4 digit year and the issue still persists.

I'd like to only enter DD-Mon - HH:MM and have it sort without the year (since our tables won't need the year field). I have tried hacking the TablePlugin.pm file around line number 139. I tried many variations on the following with no luck:

    if( $text =~ /^\s*([0-9]{1,2})-([A-Z][a-z][a-z])\s-\s([0-9][0-9]):([0-9][0-9])\s*$/ ) {
        $date = timegm(0, $4, $3, $1, $mon2num{$2}, 2002 );

-- MicahHoffman - 05 Jul 2002

Module is very nice but Im running into an issue here. We often have tables that have a summary line (usually some type of summation) at the bottom. Something like

Who Work
JC 5
SM 4
SC 2
JC 4
Total 15

It would be really useful if there was some mechanism to tell it to omit the last n rows when doing the sort.

-- JohnCavanaugh - 03 Aug 2002

As we are in the process of adding feature requests... My biggest problem with the sorting on the TablePlugin is the fact that dates are not correctly sorted. We really should have a field with characteristics "Date" which imposes a different sorting order (we could go all out and actually make the date formatting also flexible, i.e., keep it in a standard format in the file but render it in various formats. E.g., $12 Aug 2002$ could render depending on some chosen format in the preferences. Right now I am mostly concerned about the sorting, but having a standard internal representation of dates would make the sorting easier (albeit the Perl date module has very flexible date parsing options anyway).

-- ThomasWeigert - 03 Aug 2002

Just noticed the initsort only working on first table bug is still in the version I posted - I'll fix that asap assuming it is easy enough to see what needs brining across from the fix by ShawnBradford. Hm - twiki makes a hopeless cm tool...

-- DarrylGreen - 12 Aug 2002

I fixed these errors in the attached TablePluginNew.pm. I also merged in the width setting from MegaTWiki.

-- WoutMertens - 13 Aug 2002

Thanks for making this available, I will check it out and roll it back into the Plugin.

Small suggestion: This plugin and others refer to table header and footers, so instead of skipfirst and skiplast I suggest that we use skipheaderrows and skipfooterrows, respectively.

-- PeterThoeny - 13 Aug 2002

In that case, I think it would even be better to name them headerrows and footerrows, because that is what they are. skipheaderrows is the programmatic action undertaken, which has nothing to do with table contents. Novices may be afraid to fill in skipsomething, but won't think twice about filling in correct info.

-- WoutMertens - 13 Aug 2002

Agreed, shorter is better. There is one problem though, if we name it headerrows it suggests the number of header rows, which would be 2 in Darryl's example above instead of 1. Ideas, suggestions?

-- PeterThoeny - 13 Aug 2002

Well, how about extraheaderrows? And keeping footerrows. That would point out that they actually mean different things. I didn't even notice the difference before you pointed it out wink

-- WoutMertens - 19 Aug 2002

The name change debate seems to be about what makes things clear and consistent for the user. I agree using header/footer makes sense on these grounds. If we dump the "skip" word and just make it a declaration of table properties instead of procesing actions (WoutMertens original suggestion) this will also make it clearer. Continuing the clarity theme, this will mean that my example (and the code) would need to change to make headerrows = 2 equivalent to the existing skipfirst = 1. It is a trivial change to do this.

-- DarrylGreen - 20 Aug 2002

OK, headerrows = 2 sounds good. That means, default for headerrows is 1 if there is a header.

-- PeterThoeny - 20 Aug 2002 (first time editing in NS 6.2 on a new computer)

This seems like a nice addition for the TablePlugin: Javascript sortable tables. It would allow people that have working Javascript to sort their tables immediately... and others can fall back on the current method.

-- WoutMertens - 21 Aug 2002

When I first wrote it the TablePlugin did actually use Javascript. I decided to go for something more general. Using Javascript if present but falling back to server side is not trivial and keeping sorting of different types (e.g. different date format is also likely to be painful).

-- JohnTalintyre - 23 Aug 2002

Has anyone ever asked for more HTML features into TWiki tables? Specifically, fixed width across multiple tables.

Here's my use case:

I want to report status via multiple tables, one table for each of our dept.'s development phases. I want each table to be formatted the same (same column, table width). I can do this today with raw HTML on my page, but ick!

-- DavisWFrank - 06 Sep 2002

I seem to have found a small bug in the table plugin... If there is noting following a table in a page, WikiWords in the table don't get links! I'll try to demonstrate with GoodTable and BadTable.

That didn't quite work because of the WebForm on the BadTable page. And I know it's not in GoodStyle to not use a signature, but it doesn't always happen, leading to this subtle problem.

-- SethTaplin - 23 Oct 2002

I moved Seth's examples from this web to the Sandbox web and removed the form on the BadTable. Bug cannot be reproduced. Note that there is a similar bug when using tables at then end with the EditTablePlugin.

-- PeterThoeny - 24 Oct 2002

I may be misunderstanding the meaning of "up" and "down" in the sort direction (attribute "initdirection"), but it appears to me that when sorting dates the meaning of these is reversed. This is confirmed by a comparison to Excel (assuming "up" is equivalent to "ascending" and "down" is equivalent to "descending" sort order). See the example in TableSortingProblem. (Incidentally, the table sorting does not work in this web, for reasons which I don't understand.)

-- ThomasWeigert - 27 Oct 2002

Codev.TableWidthAndColumnWidth is an interesting enhancement that should go into the Plugin code.

-- PeterThoeny - 13 Nov 2002

Setting the preferences in the TablePlugin topic overrides those in WebPreferences for my Dec 2001 system. Bug or feature?

-- PeterKlausner 14 Nov 2002

Is there already a way to filter table contents, for example to extract (show) only rows which (in whole or a specified column) match a regular expression.

I would like to INCLUDE subsets of a table (containing all events for our community) in various topics (home pages of groups of our community).

-- NorbertGawor - 28 Nov 2002

IDEA!When the code for this plugin generates the table header, each <td> tag should use valign="bottom". This fixes an esthetics problem: when a column is sorted, the bottom or up arrow image is added to the column text. This results in the horizontal alignment being slightly off from the rest of the columns. It's the little things in life...

-- MartyBacke - 19 Nov 2002

But this looks odd with large font size or with wrapped lines.

-- PeterThoeny - 25 May 2003

You might want to look at what PeterThoeny did on TWikiInstallation. That interesting scheme lets you filter the table interactively. If you want to filter the table before creating the table, you might want to look at the header and format options added to search in the Beijing release (you can update your release without breaking anything else by just using Search.pm, bin/search, and bin/setlib.cfg).

-- ThomasWeigert - 01 Dec 2002

Yes, I know it can be done via SEARCH. (Thomas, thank you, for working for me, even on Sundays wink ) But what if I do not want the table to be a search result but given in plain "|...|...|" style?

BTW, I am doing it now via a separate CGI script:

-- NorbertGawor - 02 Dec 2002

May be not the right place... but perhaps is there a need for some kind of TableApi to provide :

  • something like table templates
  • be able to access a table with readtable(topic,table_name)
  • give an interface to different layers of the table (have a few perl @tables)
    • data_input
    • function
    • formating
    • value (output)
    • ???
  • implement functions (on the different layers) :
    • get_table_row()
    • get_hash(row,row)
    • render_html
    • export_excel (using CSPAN spreadsheet::writeexcel perhaps)
    • export_xxx ???
    • ???
this would allow for prefence variables to be put into a table too (when more than a few preference for 1 plugin)

as a first though at the implemention(syntax): %TABLETAG{table_template}

=align(left) put the html table in DIV left right ...

function       comments
=header(0) col1 col2 col3 define the first header
=header(1) col1 col2 col3 2nd header
=data(0) val val val 1rst row of data
=data(1) val val val 2nd row of data
=data(n) val val val other data rows
=function(0,0) =func1(arg1,arg2) =func2(arg1,arg2,arg3) =funcx(...) gives the functions on first row
=function(1,$)     =sum(..) apply the function(s) to a range (1,$). Here sum of each row
=footer(2) foot2 foot3 foot4
=format(0,$) class=class1 align=left class=sum

while the table template is using the same syntax, one would first read the template into the different perl @tables then overwright/add what is (re)specified in table. Even recursion would be possible (template of template ot temp....).

I guess you got the idea ?


  • comment/suggestions ?
  • could it be written as a Plugin ?
    • what Plugin_hook to use ? ( I am still new to TWiki)
PS: I personaly would prefer having the Microsoft Excel syntax for cell_functions(would ease migration smile ?) But what about regex ? (having been a COBOL programer in a previous life does not help much here)

-- MarcelTrap - 31 Dec 2002

Hi Marcel. Could you use the SpreadSheetPlugin instead?

-- GrantBow - 11 Jan 2003

WalterMundt contributed a nice WikiTablesNeedRowspanning patch that should go into this Plugin.

-- PeterThoeny - 18 Jan 2003

Here's an inital rowspan patch for TablePlugin, based on the version downloadable from the main topic. I've tested it for normal use, but I haven't played with sorting or other fancy TablePlugin features yet to make sure it doesn't break them somehow.

-- WalterMundt - 19 Jan 2003

Thanks Peter for integrating all the ehancements and fixes including the change to make skipfirst/last headerrows/footerrows. Attached is a fix I've been running since shortly after submitting the original skipfirst/last (now modified to use the new params) which ensures that even if the table is modified (or the parameters are just wrong) the page will still display (rather than a subscript error).

-- DarrylGreen - 30 Jan 2003

Walter, wrt. rowspan.TablePlugin.patch, I believe the ? in the line:

if( /^\s*(.*?)\s*$/ ) { # strip white spaces

is causing some problems. I'm no Perl guru, but it doesn't seem to make sense to have ? after .* in a search/replace. On my TWiki system I noticed that the fixed font markup was not being processed correctly when used within a table cell. Removing the ? fixed the problem.

-- RonKellam - 16 Feb 2003

In that case, it is required. What that does is assign $1 to the shortest string that can be made such that it is followed only by whitespace. Without the ?, which modifies the * match-repeat operator from "longest" to "shortest", trailing whitespace will end up in $1. I don't know how that's related to your issue, but the pattern with the ? in place has the effect I intend it to have

-- WalterMundt - 17 Feb 2003

Here's a small patch to allow table plugin to decode another common date format.

--- TablePlugin.pm.orig 2003-02-27 14:34:19.000000000 -0600
+++ TablePlugin.pm      2003-02-27 14:41:47.000000000 -0600
@@ -255,6 +255,13 @@
     if( $text =~ /^\s*([0-9]{1,2})\s*([A-Z][a-z][a-z])\s*([0-9]{4})\s*-\s*([0-9][0-9]):([0-9][0-9])\s*$/ ) {
         $date = timegm(0, $5, $4, $1, $mon2num{$2}, $3 - 1900);
+       #  Wed 2/26/2003 4:11 PM
+    } elsif( $text =~ /^\s*[A-Za-z]{1,3}\s+([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})\s+([0-9]{1,2}):([0-9]{1,2})\s+([AaPp][Mm])\s*$/ ) {
+       my $year = $3;
+        $year += 1900 if( length( $year ) == 2 && $year > 80 );
+        $year += 2000 if( length( $year ) == 2 );
+        $date = timegm(0, $5, $4, $2, $1-1, $year - 1900);
     } elsif( $text =~ m|^\s*([0-9]{1,2})[-\s/]([A-Z][a-z][a-z])[-\s/]([0-9]{2,4})\s*$| ) {
         my $year = $3;
         $year += 1900 if( length( $year ) == 2 && $year > 80 );
-- NathanNeulinger - 27 Feb 2003

Was there ever any work to integrate the cool work over in TablePluginColoringExtension??

-- JohnCavanaugh - 14 Mar 2003

I have added a few minor features to TablePlugin:

  • added tableFrame and tableRules parameters to support the HTML 4.0 frame and rules table attributes.
  • headerAlign and dataAlign can now be comma separated lists to allow different alignment of individual columns. The first column will be aligned according to the first value in the list, and so on. If there are more columns in the table than values in the list, the list will be traversed multiple times to obtain values for all columns. In particular, if there is only one value in the list, the parameters will behave as they used to in the unpatched version.

The patch: flexibleAlignment.TablePlugin.patch

-- JohannesMartin - 02 Apr 2003

There is a minor bug (IMHO) in table plugin with respect to the counting of columns. If there are empty cells in a row which cause cells to be joined, they are counted as one column. This causes the columnWidths parameter to be treated wrongly. It's not that big of a problem, since columnWidth doesn't make a whole lot of sense with joined cells anyways (I guess the widths of the cells should be added). My headerAlign and dataAlign extensions are also affected by this bug though, and they do make sense with joined cells.

Here's the patch: colCountFix.patch:

-- JohannesMartin - 15 Apr 2003

It would be nice if styles could be set up for multiple default table settings in the TablePlugin topic and then applied with a %TABLE{style="stylename"}% variable.

A workaround I have found for date sorting is to use the $isodate in searches. It's ugly but it works, see my home topic for an example.

-- SamHasler - 02 May 2003

This is about the columnwidths argument.

If I put '... columnwidths="20%," ...' I get

<tr><td align="xxxx" width="20em" bgcolor="#xxxxx"> wordwordword </td><td> align="xxxx" ...
and the subequent columns, the stuff between the <td> and the </td>, has no width. That's good.

But if I put '... columnwidths=",20%" ...' I get

<tr><td align="xxxx" width="" bgcolor="#xxxxx"> wordwordword </td><td> align="xxxx" width="20%" ...

I can bet that some where, some day, some programmer is going to take that empty string -- as opposed to a null string -- and evauate it to zero, so making it a zero width column frown

On galeon and IE6.0.2800 it doens't seem to matter.

While it isn't a bug, some "defensive programming" would be worth while.

The same reasoning applies, I suppose, to the other arguments that can take lists.

-- AntonAylward - 07 May 2003

The TableFormatOnTwikiOrg has currently a dark blue background for table headings with a yellow text. The problem is that links in headings get rendered in the default blue color, making the links barely visible.

The correct way is to add new parameters for link colors and visited link colors to the TablePlugin.

-- PeterThoeny - 13 May 2003

I have occasion to use dates in the form mm-dd-yyyy, mm/dd/yy, etc. and modified TablePlugin.pm (patch below) accordingly. I'm also using timegm_nocheck, as timegm was carping "day 29 out of range" on dates like "Jan 29 2003". Perhaps a sloppy hack, but I include it here 'cause it might be useful to someone else..

--- TablePlugin.pm.orig 2002-12-17 17:41:40.000000000 -0500
+++ TablePlugin.pm      2003-05-14 16:36:25.000000000 -0400
@@ -25,7 +25,7 @@
 # =========================
 package TWiki::Plugins::TablePlugin;

-use Time::Local;
+use Time::Local 'timegm_nocheck';

 # =========================
@@ -255,6 +255,11 @@

     if( $text =~ /^\s*([0-9]{1,2})\s*([A-Z][a-z][a-z])\s*([0-9]{4})\s*-\s*([0-9][0-9]):([0-9][0-9])\s*$/ ) {
         $date = timegm(0, $5, $4, $1, $mon2num{$2}, $3 - 1900);
+    } elsif( $text =~ m|^\s*([0-9]{1,2})[-\s/]([0-9]{1,2})[-\s/]([0-9]{2,4})\s*$| ) {
+        my $year = $3;
+        $year += 1900 if(length($year) == 2 && $year > 80);
+        $year += 2000 if(length($year) == 2);
+        $date = timegm_nocheck( 0, 0, 0, $2, $1, $year );
     } elsif( $text =~ m|^\s*([0-9]{1,2})[-\s/]([A-Z][a-z][a-z])[-\s/]([0-9]{2,4})\s*$| ) {
         my $year = $3;
         $year += 1900 if( length( $year ) == 2 && $year > 80 );
-- TomHowellCintron - 14 May 2003

I can't see any good way of reliably differentiating the American month first form (above as mm-dd-yyyy, mm/dd/yy) from the ddd first form. One could do it when at least one field was greater than 12, but otherwise it's likely to be based on site config.

-- JohnTalintyre - 16 May 2003

Incorporated ShawnBradford's EnhancedTablePluginSorting feature.

-- PeterThoeny - 13 Mar 2002

Yet another variant of editing tables in place is the EditTablePlugin, it can coexist with the TablePlugin.

-- PeterThoeny - 19 Apr 2002

Codev.SimpleTableEntryUsingForms seems to have some other TablePlugin fixes.

-- PeterThoeny - 31 May 2002

Hi Micah,

In the case I'm working on, <nop>ing everything in sight was not an option (the text in question was generated from a database and subsequently crammed into a javascript function call -- don't ask). I worked around it by hacking on the DatabasePlugin.

I also found that if you separate the </noautolink> tag from the table, the noautolinking works again (!?):

A Table
Main.GladeDiviney Not linked! Yay!


Finally, it bears repeating that <noautolink> is an "undocumented feature" according to DisableWikiWordLinks. A design choice with which I happen to disagree smile

-- GladeDiviney - 27 Jun 2002

I'll add my two cents in here for an additional feature. In many of the tables I make I'd like a whole column to be in fixed font . Is there any way that a parameter can be added that would apply global font settings ( italics , bold , fixed ...) on a per column basis instead of having to put it in each cell? For instance it'd be nice to do the following quickly and easily:

host IP

  • This could be done using CSS if a style could be set for columns. -- SamHasler - 28 Aug 2004

-- MicahHoffman - 10 Dec 2002

Hi Norbert -- long time no see smile
For the inverse problem, I hacked the DefaultPlugin: I needed to consolidate tables from different pages into one big report table. It builds upon the include="TableTemplate" feature of the EditTablePlugin:

  • A macro %MERGETABLE takes a table template as argument.
  • Then, any %EDITTABLE including exactly this table template ends up in the merged table.
  • A (default-) pattern excludes the table headers; if you explicitely supply a grep="your.*regexp" attribute, you should be done.
What's that good for? If you are the one and lonely editor, this approach is more complicated than one central table. For distributed responsibilities, this might be better. Reports like an XpTrackerPlugin "light" can be built from this plus a few clever table templates.

What is missing:

  • the format of the merged table is hard-wired; requires the first column to be the row number; need to find a clever syntax for the format="..." argument.]
  • the file access ignores Store.pm
  • if syntax + functionality are clean, this should go to EditTablePlugin. (Or TablePlugin, if the table identification is generic enough.)

-- PeterKlausner - 13 Dec 2002

Updated Plugin is posted:

  • Added headerrows and footerrows params (thanks to WoutMertens and MegaTWiki)
  • Added tablewidth and columnwidths params (thanks to ThorstenSommermann)
  • Added headercolor and datacolor params
  • Warning error should be fixed.

Let me know in case there are any issues.

-- PeterThoeny - 15 Dec 2002

Yet another update is posted:

  • Removed the individual Plugin settings in favor of one TABLEATTRIBUTES setting that has the same syntax like the parameters inside %TABLE{...}%. This improves the performance a bit.
  • Added code to check the preferences variable TABLEATTRIBUTES. This is useful to customize table attributes on a per-web level.

-- PeterThoeny - 17 Dec 2002

New version uploaded with these changes:

  • New |^| rule for multi row span (thanks WalterMundt)
  • Added tableframe and tablerules (thanks JohannesMartin)
  • Ignore columnwidths for multi column span
  • Validate headerrows and footerrows (thanks DarrylGreen)
  • Fixed link color problem and up/down icon color problem for dark header background
  • columnwidths=",20%" problem should be fixed (reported by AntonAylward)
  • Eased date format. Example:
    • 31-Dec-2003 - 23:59
    • 31 Dec 2003 - 23:59 - any suffix
    • 31 Dec 2003
    • 31 Dec 03
    • 31-Dec-2003

No intent to add non-standard date format to this Plugin.

JohnCavanaugh, the TablePluginColoringExtensions are too esoteric for general use, probably come also with a performance hit. Possibly a hook into the TablePlugin, e.g. an add-on Plugin for those who want these extensions?

JohannesMartin, it seems like the colCountFix patch is not needed, already included by the multi-column patch? (yes, seem right JohannesMartin - 14 Jul 2003)

A useful enhancement request: Do not bail out if cgi is not enabled (like by cache scripts), but degrade gracefully by rendering table colors, but disabling table sorting.

-- PeterThoeny - 25 May 2003

Just installed the latest version. I hadn't relised the separate ual settings had been replaced with TABLEATTRIBUTES.

I did notice a bug, previous revisions don't display their tables correctly.

-- SamHasler - 30 May 2003

Thinking about an easy way how to implement support for styles in tables without hurting either flexibility or performance too badly, I have come up with the following scheme. Three attributes can be defined to control the table's style:

  • tableclass defines the class of the table (class attribute of the table tag)
  • rowclasses defines the classes of individual rows (class attributes of the tr tag). It's an array, one element per row.
  • colclasses defines the classes of individual columns (class attribute of the td resp. th tag). This on is an array as well, one element per column.
In most cases, it is sufficient to use just one of these attributes. By using style sheets with definitions like
tr.thirdRow th.fourthColumn { ... }
we can define styles for individual cells, if that's what's needed.

My implementation is here here.

-- JohannesMartin - 14 Jul 2003

I had translated a lot of things into Brazilian Portuguese over my twikisite installations.

I am no longer a programmer (10+ years) far from it. However, I started "coding" some stuff since I noticed it would be great for improving some of the resources on my twiki intallations.

Here is one thing I just did and I think would be valuable for other people - please advise me if there is something wrong with it or how to improve it (feel free).

  • The problem: Some of my tables have date fields in Brazilian Portuguese format and some others (original TWiki, Main, Know, Sandbox etc) have them in ISO format. So, it was a problem when trying to sort by date in this scenario.
  • The solution: I went in the TablePlugin.pm and did some simple (add) coding there:
    • Added two variables on the use vars: @brMonth and %nbr2num.
use vars qw(
        @isoMonth @brMonth %mon2num %mbr2num $initSort $initDirection $pluginAttrs $prefsAttrs
    • Added the Brazilian Portuguese table of months (@brMonth) and the loading of it to the %mbr2num array.
@isoMonth     = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
@brMonth      = ( "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" );
{ my $count = 0;
  %mon2num = map { $_ => $count++ } @isoMonth;
{ my $count = 0;
  %mbr2num = map { $_ => $count++ } @brMonth;
    • Finally, did some changes on the routine to verify both tables (ISO and BR).
# =========================
# Convert text to number and date if possible
    if( $text =~ /^\s*([0-9]{1,2})\s*([A-Z][a-z][a-z])\s*([0-9]{4})\s*-\s*([0-9][0-9]):([0-9][0-9])\s*$/ ) {
        my $mes = 0;
        $mes = $mon2num{$2};
        if( $mes == 0 ) { 
            $mes = $mbr2num{$2};
        $date = timegm(0, $5, $4, $1, $mes, $3 - 1900);
    } elsif( $text =~ m|^\s*([0-9]{1,2})[-\s/]([A-Z][a-z][a-z])[-\s/]([0-9]{2,4})\s*$| ) {
        my $year = $3;
        $year += 1900 if( length( $year ) == 2 && $year > 80 );
        $year += 2000 if( length( $year ) == 2 );
        my $mes = 0;
        $mes = $mon2num{$2};
        if( $mes == 0 ) { 
            $mes = $mbr2num{$2};
        $date = timegm( 0, 0, 0, $1, $mes, $year - 1900 );
    } elsif ( $text =~ /^\s*[0-9]+(\.[0-9]+)?\s*$/ ) {
        $num = $text;
Well... I think it was what I did... Here is one table that worked really fine after the changes. Notice that you can even "mix" the date formats.

date BR date BR/ date ISO date ISO/ date MIX
01 Jan 2003 01/Jan/2003 01 Jan 2003 01/Jan/2003 01/Jan/2003
11 Mai 2003 11/Mai/2003 11 May 2003 11/May/2003 11/May/2003
15 Mai 2003 15/Mai/2003 15 May 2003 15/May/2003 15/Mai/2003
30 Mar 2003 30/Mar/2003 30 Mar 2003 30/Mar/2003 30/Mar/2003
25 Dez 2003 25/Dez/2003 25 Dec 2003 25/Dec/2003 25/Dec/2003
21 Dez 2003 21/Dez/2003 21 Dec 2003 21/Dec/2003 21/Dez/2003
21 Jan 2003 21/Jan/2003 21 Jan 2003 21/Jan/2003 21/Jan/2003
31 Mar 2002 31/Mar/2002 31 Mar 2002 31/Mar/2002 31/Mar/2002

TIP You can change it to work on other languages/date formats.

-- AndreDantas - 26 Jul 2003

I moved FrankPauw's add-on to CopyMsOfficeTableAddOn

-- PeterThoeny - 08 Aug 2003

There are problems with sorting dates although the description says:

date if format is:
   * dd-MMM-YY or dd-MM-YYYY

the dd-MM-YYYY format doesn't work.

-- AndreUlrich - 18 Aug 2003

Ok, it seems that this is just a simple typefault in the description of the TablePlugin?

Nice work AndreDantas! It is much easier to learn my users using the date format in their language, so I made the same changes in German. Maybe one day you can simply switch TWiki to a language with the correct Date formats.

Did anyone applied a search by date in which a formfield contains the date? It should be possible to sort the result the order="formfield(name)" switch.

-- AndreUlrich - 18 Aug 2003

Thank you for pointing that out. I have corrected the documentation to state that:

  • dd-MMM-YY or dd-MMM-YYYY
are supported date formats (3Ms, not 2). I didn't support dd-MM-* as it is not possible to differentiate this from MM-dd-* format. Note that the corrected help hasn't as yet been incorporated into the ZIP file at TablePlugin.

-- JohnTalintyre - 27 Nov 2003

If $footerRows is used and the table is empty, an error occurs. The following line change in the emitTable function will fix the problem.

<         if ( $footerRows && scalar @curTable > $footerRows) {
>         if ( $footerRows ) {

-- PaulineCheung - 26 Nov 2003

New Plugin version posted, fixing the error Pauline reported.

Note: This Plugin will be preinstalled in the TWikiBetaReleases and TWikiProductionReleases.

-- PeterThoeny - 02 Dec 2003

The table could be visually more consistent when with each header row, the alternating row colors restart again.

Like the table in EmbedFlashPlugin (slightly modified):

Argument Comment Example Default value
filename Filename of the movie; should have suffix .swf flashmovie.swf none
General attributes
width Width of Flash movie in pixels, or a percentage 320 100%
height Height of Flash movie in pixels, or a percentage 50% 100%
background Background color of Flash movie in hex string. If not used, no background color will be specified and the background color of the Flash movie will be used. This is the easiest way. #cccccc ""
version Flash Player version needed to view movie: version 5, 6 or 7 5 6
Advanced attributes
align HTML alignment. Possible values: "" (default), left, right, top, bottom. right ""
scale Scaling of Flash movie. Possible values: "" (default), noborder, exactfit, noscale. noscale ""
quality Playback quality (default Flash setting is "high"). Possible values: best, high, medium, low, autohigh, autolow. best high
menu Should right-click on Flash movie show a (default) menu? Possible values: true, false. Note that with the Flash 7 player the menu cannot be removed. true false
id ID of Flash movie; for general use not necessary to specify. movie2 the filename without suffix, eg. flashmovie

... it would be nice if each table row below the header would have the same background color, instead of dark below the Advanced attributes. Any way to achieve this?

-- ArthurClemens - 01 Jan 2004

New Plugin version posted, implementing Arthurs suggestion.

It was somewhat tricky since the following table should use alternating colors:

AAA aaa aaa aaa aaa
BBB bbb bbb bbb bbb
CCC ccc ccc ccc ccc
DDD ddd ddd ddd ddd

-- PeterThoeny - 02 Dec 2003

Example table created from %SEARCH variable with sortable headers

The following SEARCH works correctly on twiki.org but not on the intranet at work, and I can't figure out what's wrong. Setting debug = 1 in the table plugin page doesn't reveal any errors.

Topic: Changed: By:
YouAreHere 2006-04-29 - 07:12 - 11 PeterThoeny
WysiwygPlugin 2010-08-11 - 07:29 - 3 PeterThoeny

What goes wrong on the intranet TWiki? The headers don't get rendered so that they are sortable. However if I use TWiki markup to create a table then the headers do get rendered as sortable. Any ideas?

-- SimonHardyFrancis - 09 Feb 2004

I tracked down the problem to FormQueryPlugin. If installed then it disturbs the table generated by %SEARCH so that the header line and first result line incorrectly become a single line. See FormQueryPluginDev for a solution.

-- SimonHardyFrancis - 10 Feb 2004

The version of this plugin in CVS is not consistent with the released version. Please either update CVS or remove the "Developer Version in CVS" flag from the plugin topic. You know it makes sense!

-- CrawfordCurrie - 18 Mar 2004

Have you seen this beautiful table? (Apple ADC Reference Library). This use of color would require a few more parameters:

  • sortedheaderbg
  • sortedheadercolor
  • sorteddatabg
  • sorteddatacolor

-- ArthurClemens - 22 Mar 2004

non-maintainer update synchronized cvs with released zip version, which was ahead of the cvs version

Internal plugin version: 21 Mar 2004
Zip version: 1.14

-- MattWilkie - 02 Apr 2004

The default setting for tableplugin is a tableborder of 1 and a cellspacing of 1. When you work with CSS, the cellspacing property can't be overridden when using IE, so strange formatting 'bugs' appear. I would advise not to set any TABLEATTRIBUTES by default.

-- ArthurClemens - 10 Apr 2004

As a follow-up to my earlier post about sorted colors: how much work would it be to replace the sort image by a sorted color state?

-- ArthurClemens - 10 Apr 2004

Additional CSS support: add to first column th and td, the attribute class="first". Then a style sheet can render the first column slightly different from other columns. Would be nice to have "last" support too, but

  1. how to know the number of columns?
  2. how to deal with 1 column tables?

See patch file.

-- ArthurClemens - 11 Apr 2004

Please read my comments about the attachment table: BetterAttachmentTableForCairoRelease.

-- ArthurClemens - 11 Apr 2004

I've now also added CSS support for sort order of th; the previous patch file is updated.

The CSS I use (from pattern skin)

Example from pattern skin that shows the CSS support for sort order:
Example that shows the CSS support for sort order

  • I removed the header arrow images with the style; non-CSS browsers will still display them.
  • The line above the Size link changes with rollover.
  • First column style: all header columns have a white separator line at the left, except for the first column.

-- ArthurClemens - 11 Apr 2004

I can commit these patches myself if there is no objection.

-- ArthurClemens - 20 Apr 2004

Arthur, are the names aligned with the recent style sheet plans/changes?

I can do the packaging.

-- PeterThoeny - 23 Apr 2004

For common span names I was thinking about using just the plain name, such as 'left', 'right', and 'first'. These can occur within other blocks, such as TWikiAttachments. You get .TWikiAttachments .first and so on.

-- ArthurClemens - 23 Apr 2004

It seems like the sorting issue identified in November of 2002 is still a bug: TablePluginSortMultipleTable. I'm experiencing this problem locally. Is there a fix I don't know about or should I make a patch?

-- BradDixon - 11 May 2004

TablePlugin seems to have some problems with ModPerl if PUBURL changes between requests (ie HTTP vs HTTPS). Seems due to global variables in TablePlugin.pm. A trivial patch should fix this:

--- TablePlugin.pm_orig     2004-05-17 12:47:02.012947000 -0400
+++ TablePlugin.pm      2004-05-17 12:54:01.922600000 -0400
@@ -38,3 +38,3 @@
         $headerRows $footerRows
-        @fields $upchar $downchar $diamondchar $url $curTablePre
+        @fields $url $curTablePre
         @isoMonth %mon2num $initSort $initDirection $pluginAttrs $prefsAttrs
@@ -46,5 +46,2 @@
 $currTablePre = "";
-$upchar = "";
-$downchar = "";
-$diamondchar = "";
 @isoMonth     = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
@@ -520,2 +517,4 @@
     my $color = "";
+    my ($upchar, $downchar, $diamondchar) = ('', '', '');
     foreach my $row ( @curTable ) {

-- KenGoldenberg - 17 May 2004

Am I the only one that would like to improve sorting of the table in the case where there is mutirow span, like the following one?

Label Date
Apricot 1990
Banana 1991
Carrot 1986

If not, here is a patch

--- TablePlugin.pm.orig Sun Mar  7 15:35:20 2004
+++ TablePlugin.pm      Fri Jun 11 13:02:27 2004
@@ -488,6 +488,20 @@
             @trailer = splice( @curTable, -$footerRows );
+        # Handle multi-row labels
+        for my $row (0..$#curTable) {
+            for my $col (0..$#{$curTable[$row]}) {
+                $curTable[$row][$col][1] =~ s/ rowspan="[^"]+"//;
+                $curTable[$row][$col] =
+                  [ $curTable[$row-1][$col][0],
+                    $curTable[$row][$col][1],
+                    "td",
+                    $curTable[$row][$col][3],
+                    $curTable[$row][$col][4] ]
+                  if $curTable[$row][$col][2] eq "X";
+            }
+        }
         $stype = colType( $sortCol );
         &TWiki::Func::writeDebug( "- TWiki::Plugins::TablePlugin sorting col $sortCol as $fields[$stype]" ) if $debug;
         if( $stype ) {

-- LouisGranboulan - 11 Jun 2004

First let me say thanks to everyone for the work on the table plugin. It works great... mostly;-).

I may be trying to do some things not intended. I am trying to construct multirow search output. We are trying to report status on projects being worked. Each project has its own page with a form to collect info. Here is an example. of what I want.

ID Topic Summary
team Status comments
1 ProjectOne This is a cool project ...
My team the project is going well
1 ProjectTwo This is a neat project ...
My team the project is going bad

my actual table and search below

%TABLE{ sort="off" initsort="1" cellpadding="1" cellspacing="3" headerbg="#000099" headercolor="#FFFFCC" databg="#C8CB8F, #DBDDB5" headerrows="2" columnwidths="5%, 30%, 65%"}%
%SEARCH{ "[S]tage.*?value=.*?[A]ctive"  scope="both" regex="on" web="Myweb" nosearch="on" nototal="on" header="| *ID* | *Topic* | *Summary* | $n | *ID* | *Team* | *Status Comments* |"  format="| $formfield(TD ID)| Rustproofing.$topic |$summary  | $n  | ^ | $formfield(Support Team) | $formfield(Status Comments) | "  }%

here are the problems I've found

1. What I really wanted was for each set of rows to look like (the second data row should span cells 2 and 3)

ID Topic Summary
team Status comments
1 ProjectTwo This is a neat project ...
the project is going bad
as you can see the problem is the multicol span confuses the rendering. (We worked around this by adding data to that cell (the team name))

2. When the rows are sorted (I applied the patch above from LouisGranboulan. Before that it was all mangled) it forces in the value of the first cell in the second row. Renders as two rows not rowspan.

ID Topic Summary
ID team Status comments
1 ProjectOne This is a cool project ...
1 My team the project is going well
here is the original example table with the TABLE var used (TWiki.org must not have the patch)
ID Topic Summary
team Status comments
1 ProjectOne This is a cool project ...
1 My team the project is going well
1 ProjectTwo This is a neat project ...
1 My team the project is going bad

3. Also, as mentioned above the bug for sorting multiple tables still exists.

4. We are using a search to fill out a table with form fields. If one of the fields has a return character in it the row is rendered as plain text not as a table. I realize this is because the rows look like

| asljkdfl | laskdfjlaksjf
I don't know if this can be fixed. (we now just forbid returns and make people use br tags)

Please let me know if I can help by providing more examples or details.

-- KenKoftan - 16 Jun 2004

I have added CSS support for first column and sort ascending/descending table headers in CVS. I desperately needed this to work for PatternSkin.

  • CSS tags for the table headers are now:
    • twikiFirstCol
    • twikiSortedAscendingCol
    • twikiSortedDescendingCol

-- ArthurClemens - 26 Jul 2004

New version posted in TablePlugin and installed on TWiki.org, contains Arthurs changes.

-- PeterThoeny - 01 Aug 2004

Refactored a lot of feature request items to the #Wishlist and separated out the discussion on #Column_Sorting_Using_Javascript.

I started to create an Update section to mirror EditTablePluginDev but the update text refered a lot to the discussion. I would refactor it out and put links back to anchors in the discussion but if that discussion gets archived to TablePluginDevArchive then it would break the links. Maybe I'll refactor TablePluginDevArchive back into this topic and delete it.

Refactor; don't archive!!

-- SamHasler - 28 Aug 2004

I didn't know that you can have more than tag to a table but I just did it by accident and it works. Perhaps it should be documented and indicate which tag will take precidence. It's possable that might be useful when combined with includes.

-- SamHasler - 07 Sep 2004

Not sure if there's another fix for autolink sort quirk besides using <noautolink> </noautolink> wrappers on the table. Here's a simple patch that ignores chars at the start of a field as defined in the ignorechars var.

--- TablePlugin.pm.orig  2004-10-04 12:04:11.000000000 -0400
+++ TablePlugin.pm       2004-10-04 12:07:54.000000000 -0400
@@ -171,6 +171,8 @@
     $headerColor  = "";
     @dataBg       = ( "#FFFFCC", "#FFFFFF" );
     @dataColor    = ( );
+    # 2004-10-04 - ADP - ignore some leading chars in sort, but none by default
+    $ignorechars  = "";
     undef $initSort;

     handleTableAttrs( $pluginAttrs );  # Plugin setting
@@ -248,6 +250,10 @@
     $tmp = TWiki::Func::extractNameValuePair( $args, "datacolor" );
     @dataColor = split( /,\s*/, $tmp ) if( $tmp );

+    # 2004-10-04 - ADP - ignore some leading chars in sort (like "!")
+    $tmp = TWiki::Func::extractNameValuePair( $args, "ignorechars" );
+    $ignorechars = $tmp if( $tmp ne "" );
     return "$currTablePre<nop>";

@@ -433,6 +439,8 @@
    $text =~ s/\[\[[^\]]+\]\[([^\]]+)\]\]/$1/go; # extract label from [[...][...]] link
    $text =~ s/<[^>]+>//go;                      # strip HTML
    $text =~ s/^ *//go;                          # strip leading space space
+   # 2004-10-04 - ADP - ignore some leading chars in sort
+   $text =~ s/^[$ignorechars]//go;
    $text = lc( $text );                         # convert to lower case
    return $text;

-- AlPayne - 04 Oct 2004

Today on TWikiIRC it was reported that in the latest beta, the TablePlugin was generating the following error:

 [Thu Oct 28 22:48:30 2004] [error] [client] 
[Thu Oct 28 22:48:30 2004] view: Use of uninitialized value in pattern match (m//) at 
/usr/local/apache2/twiki/lib/TWiki/Plugins/TablePlugin.pm line 187.

The "faulty" code is (on line 187):

       return "" if( $args =~/^\s*$/ );

The error happens because the plugins try to read the TABLEATTRIBUTES preferences on the plugin topic and the TWiki/Web preferences topic. If the preference is not found in one of them then the $args value is undef, thus causing the error.

the quick fix is replace the line 187 with:

       return "" if( $args &&  $args =~/^\s*$/ );

-- RafaelAlvarez - 28 Oct 2004

The automatic sorting of columns that the TablePlugin provides, doesn't work if one has an empty cell in the header.

This example works:

Column 1Sorted descending Column 2
Hand Glove
Foot Shoe

This example fails to make the columns sortable:

Hand Glove Arm
Foot Shoe Leg
Column 1 Column 2  

Regards JC

-- JanCarstenJ - 24 Nov 2004

Can't destinguish borders when printing tables

I'm not sure it my observation is a:

  • Bug
  • Feature request
  • I don't get how to use TablePlugin
If I configure tables like they are here at TWiki.org - very neat, and use the printable link for printing then:
  • borders don't show ('cause that's how tables are configured, border=0)
  • background color doesn't show ('cause that's how browsers choose to print web pages)
Hence, I can't easily distinguish one field from the next.
It should be possible to specify separate attributes for tables in the 'print' skin.
Super nice plugin though!

Regards Holger

-- HolgerBille - 08 Dec 2004

TravisCampbell posted Support.TablePluginSortingNegativeNumbersIncorrectly with patch. Should go into the next release.

-- PeterThoeny - 11 Jan 2005

One of our users is having trouble getting tablewidth to work since we upgraded to TWikiRelease02Sep2004 with PatternSkin. It seems to be some interaction between the skin and the plugin, since tablewidth="100%" has the expected effect when I view the topic with "?skin=classic".

Any ideas? Is this a known issue with PatternSkin?

-- EdSwierk - 15 Feb 2005

have there been any discussions about Table Headers as required by the W3C for Accessibility, see the WAI standards

-- SamDetweiler - 21 Feb 2005

Table headers can be created with | *Foo bar* | syntax, but this is not enforced. Best to follow up on general accessability questions in Codev.UserAccessibilityGuidelines

-- PeterThoeny - 22 Feb 2005

I was wondering if anybody has tried to create a long table from many includes of shorter tables as I can not seem to get this to work.

-- AndyBush - 02 Mar 2005

New (2004-09) version seems to have a bug with respect to sorting multiple tables in the same topic. In my case, I am sorting one from high to low (Dates BC) and the other from low to high, (Dates, AD). The second table in the topic does not sort according to the TABLE parameters just prior. This used to work.

Let me give a specific example. The first search below searches this web for all topics starting with the letter "A", and then sorts "up" (i.e. from High to Low dates). Notice that the Very Early date and Very Late dates are incorporated into the table where they should be, even tho these are explicitly listed after the search. This first example sorts correctly on the ISO date, and incorporates the dates where they should be. [In my test topic, this works, but it does not work at all here. Why?]

Here are the statements I used:

TABLE{sort="on" initsort="2" initdirection="up"}%
SEARCH{"^[A][ABC].*" scope="topic" type="regex" nosearch="on" nototal="on" noheader="on" format="|[[$topic]]  |$isodate   |"}%

Topic Modify DateSorted descending
Very Late Date 3000-03-14T22:48Z
ActionTrackerPluginDev 2014-07-02T23:16:30Z
AbusePlugin 2013-10-16T00:28:44Z
AccessStatsPlugin 2013-10-16T00:29:48Z
ActionTrackerPlugin 2013-10-16T00:29:48Z
AccessStatsPluginDev 2011-05-03T18:02:32Z
AbusePluginDev 2011-02-25T08:07:50Z
ActionTrackerPluginAppraisal 2009-09-16T12:23:18Z
AbusePluginAppraisal 2009-09-10T14:55:05Z
AC 2006-11-14T21:02:07Z
AccessStatsPluginAppraisal 2006-02-20T18:26:51Z
ActionTrackerInput 2004-04-12T18:09:49Z
ActionTrackerPluginModified 2004-02-18T17:03:00Z
ActionTrackerPluginHistory 2004-02-06T07:13:00Z
ActionTrackerPluginDevArchive 2003-05-10T20:16:00Z
Very Early Date 1900-03-14T22:48Z

This second table Does not work correctly. initdirection is "down", meaning from low to high. (If you're like me, I never understood why these 'backwards' argument names were used -- no worries). This does not sort and does not incorporate the last two lines into the table. This used to work in the prior release.

Here are the statements I used:

TABLE{sort="on" initsort="2" initdirection="down"}%
SEARCH{"^[A][ABC].*" scope="topic" type="regex" nosearch="on" nototal="on" noheader="on" format="|[[$topic]]  |$isodate   |"}%

Topic Modify DateSorted ascending
Very Early Date 1900-03-14T22:48Z
ActionTrackerPluginDevArchive 2003-05-10T20:16:00Z
ActionTrackerPluginHistory 2004-02-06T07:13:00Z
ActionTrackerPluginModified 2004-02-18T17:03:00Z
ActionTrackerInput 2004-04-12T18:09:49Z
AccessStatsPluginAppraisal 2006-02-20T18:26:51Z
AC 2006-11-14T21:02:07Z
AbusePluginAppraisal 2009-09-10T14:55:05Z
ActionTrackerPluginAppraisal 2009-09-16T12:23:18Z
AbusePluginDev 2011-02-25T08:07:50Z
AccessStatsPluginDev 2011-05-03T18:02:32Z
AbusePlugin 2013-10-16T00:28:44Z
AccessStatsPlugin 2013-10-16T00:29:48Z
ActionTrackerPlugin 2013-10-16T00:29:48Z
ActionTrackerPluginDev 2014-07-02T23:16:30Z
Very Late Date 3000-03-14T22:48Z

-- RaymondLutz - 14 Mar 2005

Here is the correction for this problem:

    #Added to aid initial sorting direction and column : ShawnBradford 20020221
#    if ( defined( $sortCol ) ) {
#        undef $initSort;       ## COMMENTED RaymondLutz 20050323
    if( defined( $initSort ) ) {
        $sortCol = $initSort - 1;
        $up = $initDirection;
        $direction = $up ? 0 : 1;
        $requestedTable = $tableCount;
        undef $initSort;   ## ADDED RaymondLutz 20050323

The original code did not include the possibility that there would be more than one table per page.

-- RaymondLutz - 23 Mar 2005

Has anyone looked at merging JohannesMartin's patch to add tableclass, rowclasses & colclasses?

-- SamHasler - 02 Apr 2005

I liked the patch from LouisGranboulan to "improve sorting of the table in the case where there is mutirow span". Hope it will get merged in the next release.

-- NicholasSushkin - 08 Apr 2005

There is a style bug with the th header in the first column if the table is sorted on that column. The second class that is assigned to the header link is just added although another class is defined earlier on the line.

My sort_patch fixes this. It works, but the syntax might be terser - I am just a Perl hacker...

-- ArthurClemens - 09 Apr 2005

Added syntax for applying a CSS CLASS to individual cells. The TWiki text would look like this:

<style type="text/css">
.red  { background-color: #FF6666; }
.grey { background-color: #CCCCCC; }
|=red A red background |
|=grey Grey |

The resulting table should look like this:

A red background

Our company uses this for tracking priorties in iterative projects. Each iteration, we priotize risks and set the proper cell to the matching class. A style sheet controls the colors.

The patch recognizes an equal sign immediately following the vertical bar: |=class. There can be no spaces between the bar and the equal. It takes the word after the equal as a CSS class name.

-- RobertWohlfarth - 11 Apr 2005

I just noticed that TablePlugin::initPlugin() has the following code:

$url = $cgi->url . $cgi->path_info() . "?" . $plist;

I think this is wrong; shouldn't it be

    $url = TWiki::getViewUrl($web, $topic) . "?" . $plist;

? Otherwise it breaks for those of us using RelativeURLs.

Also, why is $url a package global?

-- AdamSpiers - 14 Apr 2005

Here's a patch that completes CSS support for this plugin. This adds two new arguments to the the tag:

  • tableclass: CSS class of the table, defaults to twikiTable
  • dataclass: list of CSS classes that are used for each row

Especially adding twikiTable to all TWiki tables is needed for the uppcoming release of the NatSkin.

Example code:

%TABLE{tableclass="twikiTable myTableClass" dataclass="myTableCell1, myTableCell2"}%
| *hello* | *world* |
| hello | world |
| hello | world |
| hello | world |
| hello | world |
| hello | world |
| hello | world |

<style type="text/css">
.myTableClass {
  border:2px dashed red;
.myTableCell1 {
.myTableCell2 {

-- MichaelDaum - 23 Jun 2005

The above patch has been proposed at CompleteCssControlofTWikiTables for inclusion into the DakarRelease.

-- MichaelDaum - 02 Jul 2005

Added hanging CSS styles with the syntax |+class. The style propogates to all colored rows following its first instance.

I build a table for schedules. Different milestones have different colors. Rather than place a stylesheet on every cell, I set the style sheet once and it stays until the next |+class.

-- RobertWohlfarth - 05 Dec 2005

Can you please add an example off the |+class usage, as you have done for the |=class ? I don't understand how it should be used.

-- AviYagodnick - 01 Jan 2006

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff-2003-05-25 TablePlugin.pm.diff-2003-05-25 r1 manage 3.5 K 2003-07-14 - 08:37 JohannesMartin support for styles
Unknown file formatdiff-2005-04-11 TablePlugin.pm.diff-2005-04-11 r1 manage 0.5 K 2005-04-11 - 18:40 RobertWohlfarth Allow CSS formatting on individual cells
Unknown file formatdiff-2005-06-23 TablePlugin.pm.diff-2005-06-23 r1 manage 3.1 K 2005-06-23 - 15:44 UnknownUser Adds complete CSS support
Unknown file formatdiff-2005-12-05 TablePlugin.pm.diff-2005-12-05 r1 manage 3.4 K 2005-12-05 - 21:56 RobertWohlfarth Hanging CSS formatting on cells
Unknown file formatdiff TablePlugin_CSS_first_and_sort_order.diff r1 manage 1.3 K 2004-04-11 - 13:17 ArthurClemens Adds CSS support for first column th and tds, and for sort order of th
Texttxt TablePlugin_example_style.txt r1 manage 1.1 K 2004-04-11 - 13:34 ArthurClemens Example style from pattern skin
PNGpng TablePlugin_screenshot_of_sort_order.png r1 manage 17.3 K 2004-04-11 - 13:23 ArthurClemens Example that shows the CSS support for sort order
Unknown file formatpatch colCountFix.patch r1 manage 0.4 K 2003-04-15 - 11:54 JohannesMartin fix error in computation of column numbers
Unknown file formatEXT csv-patch r1 manage 3.8 K 2005-10-19 - 03:37 MagnusLewisSmith Patch to Export table as CSV. Based on v1.013 01 Aug 2004
Unknown file formatpatch flexibleAlignment.TablePlugin.patch r1 manage 5.5 K 2003-04-02 - 08:02 JohannesMartin allow columns to have different alignment and more
Unknown file formatpatch rowspan.TablePlugin.patch r2 r1 manage 3.9 K 2003-01-19 - 10:46 WalterMundt WikiTablesNeedRowspanning patch
Unknown file formatdiff sort_patch.diff r1 manage 1.3 K 2005-04-09 - 19:13 ArthurClemens Repairs header style for first column
Unknown file formatpatch validate.TablePlugin.patch r1 manage 0.7 K 2003-01-30 - 06:04 DarrylGreen validate headerrows and footerrows patch
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2006-12-14 - RaymondLutz
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.