[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" | Jahr!!rowspan="2" | Gewinner!!rowspan="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

bzimport added a project: MediaWiki-JavaScript.Via ConduitNov 22 2014, 12:48 AM
bzimport set Reference to bz38911.
Schnark created this task.Via LegacyAug 1 2012, 9:20 AM
TheDJ added a comment.Via ConduitApr 25 2013, 9:31 AM

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
}
gerritbot added a comment.Via ConduitApr 25 2013, 3:50 PM

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

Schnark added a comment.Via ConduitApr 26 2013, 9:30 AM

(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).

TheDJ added a comment.Via ConduitApr 26 2013, 10:09 AM

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

matmarex added a comment.Via ConduitJul 1 2013, 3:41 PM

Fixed by DJ. Yay!

gerritbot added a comment.Via ConduitJul 1 2013, 3:43 PM

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

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

bzimport added a comment.Via ConduitOct 6 2013, 2:04 PM

zedlightman wrote:

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
}
matmarex added a comment.Via ConduitDec 8 2013, 10:37 PM

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

matmarex added a comment.Via ConduitMar 1 2014, 5:08 PM

(It has been merged now, at last.)

Add Comment