Tags:
create new tag
view all tags

Bug: Sorting tables that use rowspan fails

Since sorting only reorders the rows in the table, rowspan appear in wrong places. A solution is to repeat the content of the spanned row when sorting is done. Here is a patch that implements this solution.

--- 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 ) {

Test case

Theme Date
Apricot 1990
1997
Banana 1995

Environment

TWiki version: TWikiBetaRelease2004x03x20
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin, TablePlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

The bug is in TablePlugin $VERSION = '1.012'; # 01 Dec 2003 It is independent of the TWiki version or the environment.

-- LouisGranboulan - 11 Jun 2004

Follow up

Thanks Louis. I have seen that you posted the bug and fix also in the TablePluginDev topic (which is where it belongs). I set this bug report to N/A ("rejected") since the Codev bug tracking is just used for the core code and doc.

Fix record

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2004-06-11 - PeterThoeny
 
  • 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-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.