Page MenuHomePhabricator

[Tablesorter] Headers with rowspan should be considered for all rows
Closed, ResolvedPublic

Description

This is hard to describe. I hope the example at https://commons.wikimedia.org/w/index.php?title=Commons:Sandbox&oldid=75246712 explains, what I want to say.

As far as I understand currently the code looks for the header row with most cells, to decide which cells can be clicked to sort the table (function buildHeaders). But it should look at the row with the most *columns*, i.e. count cells after considering rowspan (which is somewhat contrary to bug 31420).

With a header like

{| class="wikitable sortable"
!rowspan="2" | Jahrrowspan="2" | Gewinnerrowspan="2" | Nationalität!!colspan=5|Score

-

! R1 R2 R3 R4 Total

-

not only the columns labeled R1 to Total (in the second row) should be sortable, but also the first three columns, which span over two rows and currently aren't considered as there cells belong to the first row.

My example shows a workaround for this:

{| class="wikitable sortable"
! style="border-bottom: hidden;" | style="border-bottom: hidden;" | style="border-bottom: hidden;" | !! colspan=5|Score

-

! Jahr Gewinner Nationalität R1 R2 R3 R4 !! Total

-

which just adds an invisible cell in the first row, and moves the header in the second row. But the text should be centered vertically, and the whole header (both rows) should be clickable.


Version: 1.22.0
Severity: enhancement
URL: https://commons.wikimedia.org/w/index.php?title=User:Schnark/tablesorter&oldid=95146565

Details

Reference
bz38911

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:48 AM
bzimport set Reference to bz38911.

The buildHeaders() function should take into account rowspan when calculating 'longest' TR and collecting the TH's cells that will get the sorter added, for this to work. Simple test case:

{| class="wikitable sortable" border="1"

-

! rowspan=2 | name
! colspan=2 | Data columns

-

! data
! more data

-
cats
273
53
-
dogs
65
8,492
-
mice
1,649
548
}

Related URL: https://gerrit.wikimedia.org/r/60871 (Gerrit Change I172c3a610b28498334f80a7808663bab7fb0466c)

(In reply to comment #0)

This is hard to describe. I hope the example at
https://commons.wikimedia.org/w/index.php?title=Commons:
Sandbox&oldid=75246712
explains, what I want to say.

Now at [[commons:User:Schnark/tablesorter]] (ignore the red links/templates, it's just about which columns should be sortable).

@Michael, tested that case with my change, and it works as desired.

Change 60871 merged by jenkins-bot:
jquery.tablesorter: Support sortable column headers with rowspans

https://gerrit.wikimedia.org/r/60871

The last fix does not work in this case:
*[[Help talk:Sorting]] - see section "Sorting not working with complex headers".

{| class="wikitable sortable"

-

! rowspan="2" | name
! colspan="2" | Data columns
! rowspan="2" | Another column

-

! data
! more data

-
cats
273
53
1
-
dogs
65
8,492
2
-
mice
1,649
548
3
}

Timeshifter, patch for bug 53211 – https://gerrit.wikimedia.org/r/#/c/98250/ – should fix that as well.

(It has been merged now, at last.)