You are here: Foswiki>Tasks Web>Item8647 (17 Dec 2011, GeorgeClark)Edit Attach

Item8647: TablePlugin generates empty tfoot, even when there are footer rows

Priority: Urgent
Current State: Closed
Released In: 1.1.4
Target Release: patch
Applies To: Extension
Component: TablePlugin
Reported By: CrawfordCurrie
Waiting For:
Last Change By: GeorgeClark tries to generate thead and tfoot for tables, based on the rows in a TML table. Thus
| *Head* |
| Body |
| *Toe* |
should generate
but it doesn't, it generates
This is a PITA for any client-side table handlers, as they have to recognise the empty tfoot and process it.

-- CrawfordCurrie - 02 Mar 2010

I just checked again on trunk and it's even worse. Now it generates the first two rows in the thead and the footer row in the tbody!

The fault is in the TablePlugin, and is urgent.

-- CrawfordCurrie - 13 Oct 2011

Possible unit test:

---   (revision 12748)
+++   (working copy)
@@ -1115,4 +1115,36 @@
 #    );
+# make sure thead, tbody, tfoot are generated correctly
+sub test_thead_tfoot {
+    my $this = shift;
+    my $tml = <<TML;
+| *Head* |
+| Body |
+| *Foot* |
+my $html = <<HTML;
+<table class="foswikiTable" rules="none" border="1">
+ <thead>
+  <tr class="foswikiTableOdd foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
+   <th class="foswikiTableCol0 foswikiFirstCol foswikiLastCol">Head</th>
+  </tr>
+ </thead>
+ <tbody>
+  <tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
+   <td class="foswikiTableCol0 foswikiFirstCol foswikiLastCol">Body</td>
+  </tr>
+ </tbody>
+ <tfoot>
+  <tr class="foswikiTableOdd foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
+   <th class="foswikiTableCol0 foswikiFirstCol foswikiLastCol foswikiLast">Foot</td>
+  </th>
+ </tfoot>
+    $this->do_test($html, $tml);

-- CrawfordCurrie - 13 Oct 2011

According to - Note: <tfoot> must appear before <tbody> within a table, so that a browser can render the foot before receiving all the rows of data.

We do not have any tests that cover tables with the TablePlugin disabled. I've added some tests to the FormattingTests, and it appears that the core Render code doesn't support table footers. It emits the "footer" row as a body row with strong emphasis.

-- GeorgeClark - 13 Oct 2011

Committed a fix in the way the header and footer rows are counted. Needs further validation for unusual table layouts - (header/footer row that's embedded in the middle of the table).

Also not sure that the plugin is completely correct. It assumes that any bold cell is a th cell, and any row with all th cells is a header row. I suspect that:
  • Cells should be th only when part of a header - ie all cells are th in the row.
  • Rows that are embedded in the table and are all bold, are not really header or footer. I suspect this layout might break things.

-- GeorgeClark - 15 Oct 2011

Indeed, there were still issues. Added the following test cases
  • Bold cells when no header or footer is present should not be sortable
  • Bold cells after the header before the footer should not be sortable. If no header, the footer still has to have the sort links.

Modified the code to only emit the sort links when it is really the last header row or first footer row.

-- GeorgeClark - 15 Oct 2011

Marking this fixed in the ReleaseNotes01x01. But leaving the task waiting for Feedback. I'd like CDot to verify the interaction with the client side table handler he referred to in the original report.

-- GeorgeClark - 24 Oct 2011

Looks good.

-- CrawfordCurrie - 02 Nov 2011

Topic revision: r16 - 17 Dec 2011, GeorgeClark - This page was cached on 19 Mar 2019 - 06:41.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy