User:Tcncv/Table Sort Demo

From Wikipedia, the free encyclopedia

This page contains several tables used to demonstrate proposed colspan/rowspan enhancements to Wikipedia table sorting functions. To view the enhancements in operation, you must add importScript('User:Tcncv/sorttables.js'); to your monobook.js file (or appropriate xxx.js file for your chosen skin).

In addition to these tables, you can try the functionality on your own tables (on a suitable test page - not mainspace) by adding class="wikitable tsx_sortable" to the table header. The class="autorowspan" attribute can also be added to columns or the entire table to maximize cell merge operations.


Test table adapted from Swimming at the 2008 Summer Olympics[edit]

Another example: 2008 Olympics Medal table[edit]

Note that the Rank column has a number of merged cells, but when the table is sorted, they are split, so that the table layout is not corrupted. If you sort by Rank again, previously merged cells are recombined. Also, if you sort a number of adjacent columns right to left (uch as Bronze, Silver, then Gold), cells are merged in all these columns. (That may not be desirable in all cases, but for this example, its been enabled.)

Another example: 2008 Olympics Medal table (with multirow header)[edit]

Note that the Rank column has a number of merged cells, but when the table is sorted, they are split, so that the table layout is not corrupted. If you sort by Rank again, previously merged cells are recombined. Also, if you sort a number of adjacent columns right to left (uch as Bronze, Silver, then Gold), cells are merged in all these columns. (That may not be desirable in all cases, but for this example, its been enabled.)


What happens when rowspan and colspan conflict[edit]

Overlapping row spans and column spans are invalid in HTML and are not supported by the updated sortable script. These examples are included just to see how they render.

Examples from Help talk:Sorting[edit]

... plus a small sample of mainspace articles that currently have sorting problems.

Example 1[edit]

From Statewide opinion polling for the Democratic Party presidential primaries, 2008#Delegate table and polling data referenced from Help talk:Sorting#Rows/headers above sortable row.

Demonstrates multi-row headers with rowspans and fixed (unsortable) footer.

Example 2[edit]

Example from Help talk:Sorting#Can this be got working?

Demonstrates multi-row headers with rowspans and colspans.

Example 3[edit]

From List of Colorado Avalanche players#Goaltenders referenced from m:Help talk:Sorting#Table with colspanned cells.

Demonstrates multi-row headers with rowspans and colspans.

Example 4[edit]

From Comparison of email clients#Protocol support referenced from m:Help talk:Sorting#problem with 2 row - header - table.

Demonstrates multi-row headers with rowspans and colspans. Sort icons are suppressed on some header cells. Also changed "sortbottom" to "unsortable" to stablize the footer rows.

Example 5[edit]

From Anamorphosée#Singles

Demonstrates multi-row headers with rowspans and colspans and rowspans in the data.

Example 6[edit]

From In Blue#Charts and certifications

Demonstrates rowspans in the data.

Example 7[edit]

From List of British Columbia senators#Current

Demonstrates a colspan in the header that previously caused sort icons to sort the wrong columns.

Example 8[edit]

From TV Land Award#Past winners

Demonstrates rowspans in the data.

Example 9[edit]

From Eurovision Song Contest winners#Winners

Demonstrates rowspans in the data and the use of unsortable and autorowspan column options added by other editors.

(Note: Editors of that article has already marked up the table, even though this functionality is not yet generally available.)

Mix of colspans and rowspans[edit]

The following data is not real, it has been adapted/fabricated to test assorted complex rowspan/colspan combinations. Note that the data in the first set of columns matches the data in the second set.


An example from MediaWiki talk:Common.js[edit]

Another table with a header containing rowspan and colspan from this discussion.


Cite error: There are <ref group=N> tags on this page, but the references will not show without a {{reflist|group=N}} template (see the help page).