Eisspeedway

Help talk:Sortable tables: Difference between revisions

Content deleted Content added
DePiep (talk | contribs)
Gadget850 (talk | contribs)
Cleanup: subpages are enabled in the Help subspace.
Line 445: Line 445:


::I don't know anything about the German stuff. As for the linking to user pages, if it was prohibited on help pages the bots would have removed it long ago. They do so on article pages. I link to user sandbox pages from many talk pages. People use external links in the body of help pages, and not in reference format. Can help pages have subpages? If so, the row number columns can be moved there. --[[User:Timeshifter|'''Timeshifter''']] ([[User talk:Timeshifter|talk]]) 13:33, 10 November 2014 (UTC)
::I don't know anything about the German stuff. As for the linking to user pages, if it was prohibited on help pages the bots would have removed it long ago. They do so on article pages. I link to user sandbox pages from many talk pages. People use external links in the body of help pages, and not in reference format. Can help pages have subpages? If so, the row number columns can be moved there. --[[User:Timeshifter|'''Timeshifter''']] ([[User talk:Timeshifter|talk]]) 13:33, 10 November 2014 (UTC)
:::Yes, subpages are enabled in the Help subspace. I don't know that there is a specific prohibition, but it is not a good idea. --<span style="color:Turquoise">''''' &nbsp;[[User:Gadget850|Gadget850]]'''''<sup>[[User talk:Gadget850|&nbsp;''talk'']]</sup></span> 14:24, 10 November 2014 (UTC)

Revision as of 14:24, 10 November 2014

WikiProject iconWikipedia Help NA‑class
WikiProject iconThis page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the Help Menu or Help Directory. Or ask for help on your talk page and a volunteer will visit you there.
NAThis page does not require a rating on the project's quality scale.

Adding mid-stream or floating headers

It would be nice to have some way, for long tables with several columns, to repeat the header, or have it floating when you scroll down, or *something*, without having to disable sortability or end up with all the spare headers bunched together if you sort. Is there any way to do this?

Several basic approaches I can imagine:

1. have a way to basically say "ignore this line when you're sorting, this is row 20 regardless of what goes on around it" or the like

2. have a way to make a table automatically spit out a "header" line every 20 rows (or whatever)

3. use framing or the like to have a "floating" header line that stays visible when you scroll past the header

This is particularly a problem for the "vampire traits" page. It has *huge* tables, mostly consisting of columns with entries like "yes", "fatal", "no", and the like. Tamtrible (talk) 00:52, 11 July 2013 (UTC)[reply]

Yes, this would be nice, and we have a ticket for adding 'floating' headers. I actually tried it a couple of times already, but there are some difficulties in implementing it. (Having to do with cloning the headers and events, when we use collapsible or sortable tables as well as the fact that we can and do have very complex spanning of columns and rows in headers). The other solutions, are in my opinion hacks, which we shouldn't implement. —TheDJ (talk • contribs) 08:42, 11 July 2013 (UTC)[reply]
Given the problems you're having doing this "right", this may be a "the perfect is the enemy of the good" situation. At least as an interim measure until floating headers are sorted out, having some way to repeat headers would be helpful. And, independent of the header issue, I can see some utility to having the ability to make lines that are ignored by sorting--for example, adding little markers to a long table to indicate where the middle of the table is, so it's easier to tell what entries are above and below average. Tamtrible (talk) 22:22, 14 July 2013 (UTC)[reply]
Any progress? she asks hopefully Tamtrible (talk) 20:42, 18 November 2013 (UTC)[reply]

Table with more complex headers

See section higher up: #Sorting not working with complex headers. I copied this table from that section so as to focus discussion.

name Data columns Another column
data more data
cats 273 53 1
dogs 65 8,492 2
mice 1,649 548 3
{| 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
|}

I read that there is a patch being reviewed that may fix this. See comment 8 in bugzilla:38911: "Timeshifter, patch for bug 53211https://gerrit.wikimedia.org/r/#/c/98250/ – should fix that as well."

So when this table works, that means the patch code has been installed. --Timeshifter (talk) 08:07, 9 December 2013 (UTC)[reply]

Patch has been installed. I see that this table is now sorting correctly. See comment 9 in bugzilla:38911: "It has been merged now, at last." --Timeshifter (talk) 14:45, 9 April 2014 (UTC)[reply]

Sorting problem with complex table caption

I've been working for more than an hour with edit previews to make the table at Template:Boxer Rebellion sortable, but it's not working! The problem seems to come from the complex table caption, which contains the table title, an image file, and an image caption. Three different things happen depending on what code I use to introduce the table caption:

  1. When I use the recommended "|+" code, some of the caption displays outside the table and the border for the caption cell disappears.
  2. When I use a regular "|" for the caption cell, the caption displays fine, but the table becomes unsortable even if it has "class=wikitable sortable" on top.
  3. Finally when I use "!" as code, the table becomes sortable again, but the caption cell displays with the same background color as cell headers and with bold fonts on everything.

Here's my table for the third example:

{| class="wikitable sortable" border="1" align="right" style="margin-left: 1em; text-align:right;"
|-
! colspan="4" align="center" cellspacing="0" | '''Forces of the [[Eight-Nation Alliance]]<br/> <small>Relief of the [[Beijing Legation Quarter|Legations]]</small>'''<br>[[File:Troops of the Eight nations alliance 1900.jpg|300px]]<br><small><center>Troops of the Eight-Nation Alliance in 1900.<br>Left to right: Britain, United States, Australia<ref>[http://www.4808.info/html/2008-05/4469p2.html Example of Australian uniform of the period]</ref>, British India,<br> Germany, France, Austria-Hungary, Italy, Japan</center></small>
|-
! align=center | '''Countries'''
! align=center | '''Warships'''<br/> <small>(units)</small>
! align=center | '''Marines'''<br/> <small>(men)</small>
! align=center | '''Army'''<br/> <small>(men)</small>
|-
|[[Empire of Japan|Japan]] 
|18
|540
|20,300
|-
| [[Russian Empire|Russia]]
| 10 
| 750 
| 12,400 
|-
| [[British Empire|United Kingdom]]
| 8 
| 2,020 
| 10,000
|-
| [[French Third Republic|France]]
| 5 
| 390 
| 3,130
|-
| [[United States]]
| 2 
| 295 
| 3,125
|-
| [[German Empire|Germany]]
| 5 
| 600 
| 300
|-
| [[Austria–Hungary]]
| 4 
| 296
| 
|-
| [[Kingdom of Italy (1861–1946)|Italy]]
| 2 
| 80 
|
|-class="sortbottom"
| '''Total'''
| 54 
| 4,971 
| 49,255
|}

I'm not competent enough with tables to figure this out, so I'd be very grateful for your help! Cheers, Madalibi (talk) 12:11, 21 February 2014 (UTC)[reply]

This is not directly helpful, but allow me to ask: why? Why is it necessary to have a table of 8 rows sortable? I suggest that the average reader is well capable of judging the relative strengths of the alliance's members just by looking at the table. -- Michael Bednarek (talk) 13:17, 21 February 2014 (UTC)[reply]
Good point, especially since the number of ships is usually proportional to the number of troops, so that the order of countries is always about the same. But having spent so much time on this (actually much more than an hour), I'd like to know the technical solution so that I can both format this table properly and solve this kind problem in other, more complex tables in the future. Madalibi (talk) 14:07, 21 February 2014 (UTC)[reply]

class=sortkey

I use class=sortkey (in a span). Works good for me. Shouldn't it be in the doc, or is it deprecated? -DePiep (talk) 19:19, 18 April 2014 (UTC)[reply]

Can't get simple table to sort

At List of largest lakes and seas in the Solar System, I specified that the columns were to sort by "number", and set the data-sort-value for individual cells (with and without commas in the values), but I can't get the table to sort numerically. What am I doing wrong? — kwami (talk) 19:24, 24 April 2014 (UTC)[reply]

Now that the colspan parameter has been removed, it works for me. -- Michael Bednarek (talk) 03:39, 25 April 2014 (UTC)[reply]
Thanks! I never would have thought of that. — kwami (talk) 05:06, 25 April 2014 (UTC)[reply]

Chinese language names sorting

Can anyone direct me to an explanation of the Chinese language name sorting defaults used in 'wikitable sortable'? This is in connection with the article List of power stations in China (for example Coal). Thank you. Kleinzach 07:33, 8 May 2014 (UTC)[reply]

Weird purple "unsortable" table for sortable

Can someone please check List of Indian states and territories by highest point.

Am I the only one seeing the first table as an unsortable and purple colored? The second table is working fine for me.

If others are not facing this problem, any idea why I could be having it?

Thanks. Ashinpt (talk) 09:34, 19 June 2014 (UTC)[reply]

Fixed - someone had damaged the sidebar, {{Lists of states and territories of India}}. Articles using this sidebar may need a purge to have their formatting repaired. -- John of Reading (talk) 09:52, 19 June 2014 (UTC)[reply]
Gee... Thanks for your help, mate. Ashinpt (talk) 10:27, 19 June 2014 (UTC)[reply]

When I click one of the headers, the year column breaks into individual lines but nothing else happens. I'm on Chrome. Darkwarriorblake / SEXY ACTION TALK PAGE! 20:42, 10 July 2014 (UTC)[reply]

Sorting is working for me in Firefox. --Timeshifter (talk) 14:41, 11 July 2014 (UTC)[reply]
Doesn't work for me in Chrome, Firefox or IE. Darkwarriorblake / SEXY ACTION TALK PAGE! 20:41, 11 July 2014 (UTC)[reply]
I have the same behavior as Darkwarriorblake on Firefox and Chrome (on Linux) whether sorting by Category, Recipient, or Award. Almost certainly the problem is the rowspan to construct the table. —EncMstr (talk) 22:36, 11 July 2014 (UTC)[reply]

Sorting is working for me in Firefox and Internet Explorer (I don't have Chrome) in this revision of the table:

Let us check the easy stuff first. Do the previous posters have problems with complex headers? From Help:Sorting: Section titled: "Tables with complex headers":

Supposedly, people should no longer have a problem with this table below. Sorting is working for me. Is it working for you?

name Data columns Another column
data more data
cats 273 53 1
dogs 65 8,492 2
mice 1,649 548 3

If that table sorts for you, then the next step is figuring out what is happening farther down in the table in question. I am just trying to get a base line of what is working for all of us. --Timeshifter (talk) 13:52, 12 July 2014 (UTC)[reply]

Checking more revisions I see that sorting works for me (Firefox and Explorer) in this later revision:
https://en.wikipedia.org/w/index.php?title=List_of_awards_and_nominations_received_by_Game_of_Thrones&oldid=616558443
The very next revision does not have sorting working for me:
https://en.wikipedia.org/w/index.php?title=List_of_awards_and_nominations_received_by_Game_of_Thrones&oldid=616572153
Here is the diff between those 2 revisions:
https://en.wikipedia.org/w/index.php?title=List_of_awards_and_nominations_received_by_Game_of_Thrones&diff=616572153&oldid=616558443
--Timeshifter (talk) 14:04, 12 July 2014 (UTC)[reply]
I think the simple solution is to remove all the rowspans in the body of the table. See new section in Help:Sorting titled "Avoid rowspan in body of table". --Timeshifter (talk) 16:34, 12 July 2014 (UTC)[reply]
Thanks for the feedback, it was a miscounted number of rows, should've been "49" and not "50", it now appears to be working for me. I get what you're saying regarding rowspan but I think as a default, using rowspan makes the table look much more presentable, while sorting adds those individual fields in without an editor having to provide the text themselves in the code to present 2 dozen "66th Annual Emmy" fields. Darkwarriorblake / SEXY ACTION TALK PAGE! 18:39, 12 July 2014 (UTC)[reply]
Yes, but once it's done, it's done. No more stress and pain for various editors fixing this stuff over and over. Plus it allows you to better use an easy online table editor such as this one:
http://wikitable.eu5.org
Try it and see what I mean. Without rowspans it is easier to change the underlying framework of a table, and move stuff around. Once the wikitext framework is simpler, the online table editor is simpler too. Because you don't have to muck around in the wikitext frame as much. --Timeshifter (talk) 15:07, 13 July 2014 (UTC)[reply]

Which algorithm is used?

Which algorithm is used by the Wikimedia software to sort sortable tables? This question seems to be not of interest concerning practical uses, but it determines wether the sort is stable (when I have understood the term "stability" in algorithm theory correctly), and finally, it influences the user experience (a stable sorting algorithm would allow him to easily sort by various criteria simultaneously). — Preceding unsigned comment added by 2003:45:CB20:E622:3D7B:4EA5:BF9B:189E (talk) 19:47, 23 September 2014 (UTC)[reply]

You might also check out these pages, mw:Help:Sorting, m:Help:Sorting, and their talk pages. --Timeshifter (talk) 00:10, 24 September 2014 (UTC)[reply]
merge sort? Frietjes (talk) 00:14, 24 September 2014 (UTC)[reply]

Date sort apparently only working in Chrome

I have what I think is a fairly simple sortable table, Table of models with four sortable columns, two number and two date. All work fine in Chrome v37 on both Win7 (64 bit) and WinXP but the date columns don't sort in IE8/XP, IE11/Win7 or Firefox 31. The first column, Date, sorts fine in all systems. I'm thinking about going to data-sort-type="number" and using embedded sort values as a work around. Anyone else have the same problem? Any help would be appreciated? Tom94022 (talk) 21:51, 9 October 2014 (UTC)[reply]

Please have a look here: Help:Sorting#Date sorting problems --Timeshifter (talk) 07:02, 10 October 2014 (UTC)[reply]
I actually developed the Table of models based upon Help:Sorting#Year_and_month using data-sort-type="isoDate" for two columns. FWIW the three data-sort-type columns in Help:Sorting#Year_and_month all fail in the same way on my FF31/XP and IE11/Win7 systems, the directional icon at the top of the column changes state but there is no sorting. The number type sorts work. So it is either a setup problem in my two systems or a bug in the code. Since the number type seems to work I guess I will switch to that type of sort and use values to force sort order. Any idea what may be wrong - Java installations perhaps? Any one else see this problem? Tom94022 (talk) 17:39, 10 October 2014 (UTC)[reply]
I converted one column to number sort and it worked in both FF and IE11 Tom94022 (talk) 21:19, 10 October 2014 (UTC)[reply]
I think you misread Help:Sorting#Year and month. I clarified the intro to that section just now by bolding the part about "does not work". I only remember this stuff when I come back here and read what I wrote long ago. :) I only wrote some of the help page. So I am not really an expert. And I did not develop the code. You said that the number type sorts work. Number sorting has many rules. You will have to read the relevant sections carefully, and experiment. Let us know what you discover, and what needs to be changed in the help page. Please link to specific revisions in stuff you are explaining so that we are talking about the same thing. --Timeshifter (talk) 02:11, 11 October 2014 (UTC)[reply]
I guess I was fooled by the working example into misreading the note, so I rewrote it to make it clear what to avoid. Hope you approve, rewrite if you wish. As far as using data-sort-type="number" to sort dates, I just put data-sort-value="yymmdd"| Month Year into each cell and it is working so far. Thanks for supporting the article. Tom94022 (talk) 06:30, 11 October 2014 (UTC)[reply]
Thanks for clarifying the help page. --Timeshifter (talk) 07:23, 11 October 2014 (UTC)[reply]

Colspan still unsortable?

Hello,

I was trying (on the French Wikipedia) to create sortable tables with both "rowspan" and "colspan" attributes. As it wasn't working I tried tables with "rowspan" or "colspan" only. The first ones are working well, but none of the tables with "colspan" do. After some research (including information on this page) I found that "colspan" was still preventing sortable tables to work well. I'd like to know if there has been any improvement regarding this issue lately, and if not why this bug page was closed in Bugzilla while "colspan" is still breaking table sorting.

Encolpe (talk) 08:15, 14 October 2014 (UTC)[reply]

Can you link to revisions of the page with and without the problems? --Timeshifter (talk) 15:22, 15 October 2014 (UTC)[reply]
Hello Timeshifter,
For example, the first two tables on Prix Eisner. Titles ("titres") and artists ("dessinateur") sort well, but then it's chaos.
Thanks Encolpe (talk) 20:00, 15 October 2014 (UTC)[reply]
Looks like bugzilla:8028 needs to be reopened. :) The sorting code has gone through a lot of changes over the years. Please leave a message in that bugzilla thread. I don't have time. And it sounds like you have some experience trying out "rowspan" or "colspan" in various tables. --Timeshifter (talk) 02:24, 16 October 2014 (UTC)[reply]
Yes, I love to do nice tables lol
I'll try to have the bug report reopened but I'm afraid I won't be able to do anything more to help solving the problem.
Thank you for your help anyway! Encolpe (talk) 09:19, 16 October 2014 (UTC)[reply]

Hi! I created a new Bigzilla Report, still unsuccessfully so far ;) Encolpe (talk) 08:02, 2 November 2014 (UTC)[reply]

A correct table forbidden?

The help page now says: "Avoid rowspan in body of table". I find this a bit too strong. As we know, these days the rowspan is undone when a reader clicks a sortbutton (the table is turned into single-rows only with repeated cellcontent: all correct).

Indeed, adding rowspan is a complicating, but I don't see why it should be "avoided" (no exception mentioned!).

First of all, adding rowspan can be desirable before any sorting comes in play. It is a basic table feature. Second, using rowspan and sorting correctly, why not? The "avoid" 'advice' (actually to be read as a MOS guideline) does not prove that is causes errors or a wrong reader experience.

I suggest the wording is changed. There could be a warning in there, but not a scare. And to be clear, I am not planning to undo the pages where I applied rowspan in a sortable. -DePiep (talk) 08:34, 17 October 2014 (UTC)[reply]

I changed the wording so that it is less strong. Now the heading says "Difficulty of rowspan in body of table". --Timeshifter (talk) 05:29, 19 October 2014 (UTC)[reply]
OK, but the wording is a bit off too. For example, the second paragraph is about writing the correct table, which could be indeed, but that is independent of the sort option. I prefer reducing the non-sort text, and remove all scaring stuff. That is not help. -DePiep (talk)
I don't understand. What exactly is incorrect? --Timeshifter (talk) 21:39, 21 October 2014 (UTC)[reply]

Heading background color on sortable tables

Template:Bug I'm building the List of mammals of Oregon which currently has sortable tables with a background color, but it does not have the arrows pointing up and down in the column header, like most of the other sortable tables do.

Header with color background example:

Name Species Authority Family State distribution and notes Red List
Virginia opossum
Didelphis virginiana
(Kerr, 1792)
Didelphidae introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption
7

Header with arrow but no color example:

Name Species Authority Family State distribution and notes Red List
Virginia opossum
Didelphis virginiana
(Kerr, 1792)
Didelphidae introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption
7

Is there a way to have both the arrows and the background color? Gaff ταλκ 21:29, 25 October 2014 (UTC)[reply]

I did not find a solution either. I sometimes use this compromise:

Name Species Authority Family State distribution and notes Red List
 
Virginia opossum
Didelphis virginiana
(Kerr, 1792)
Didelphidae introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption
7
Also helps me out when column titles are crammed and can use extra space. Separating the sortbuttons and text always looks nicer to me. -DePiep (talk) 01:32, 26 October 2014 (UTC)[reply]
Does not show well in mobile view (no sort buttons, so makes an empty row). -DePiep (talk) 01:32, 26 October 2014 (UTC)[reply]

Thank you. Somebody at the Help Desk showed me a solution and I came up with this:

Name Species Authority Family State distribution and notes Red List
Virginia opossum
Didelphis virginiana
(Kerr, 1792)
Didelphidae introduced early 1900s; adverse impacts on native bird populations from nest disturbances and egg consumption
7

Gaff ταλκ 01:46, 26 October 2014 (UTC)[reply]

So one writes:
!style="background-color:#FFDEAD;"|Name
not
!style="background:#FFDEAD;"|Name
Glad to learn this. -DePiep (talk) 02:22, 26 October 2014 (UTC)[reply]
I clarified a heading in Help:Sorting concerning combining header styling and sorting. --Timeshifter (talk) 03:11, 26 October 2014 (UTC)[reply]
I added styling workaround 2 to Help:Sorting in the section concerning combining header styling and sorting. The second row of headers below the main row of headers is useful when the width of the monitor is inadequate for the number of columns. --Timeshifter (talk) 06:45, 27 October 2014 (UTC)[reply]
Why call it a workaround? Is it not a correct difference within css we usually don't notice? Or, if it is a workaround in wiki software (as the bug indicates), why bother the editor with it as an issue? Maybe a subheader like "background colors in sortable headers" would help-page visitors more.
I'll apply this to my earlier example (split sort buttons row), just to check myself. Looks OK.
Example #5 (is #3 adjusted):
Name Species Authority Family State distribution and notes Red List
 
Virginia opossum Didelphis virginiana
(Kerr, 1792)
Didelphidae introduced early 1900s; etc.
7
-DePiep (talk) 09:21, 27 October 2014 (UTC)[reply]
Yes, "Background colors in sortable headers" is a clearer heading for that section on the help page. I moved the other info to a new section called "Putting sorting buttons below header text". --Timeshifter (talk) 06:52, 29 October 2014 (UTC)[reply]

Tables with complex datarows

DePiep. You can reword stuff, but not wholesale remove whole sections as you did here. Not without discussion. We already changed the title as you requested. --Timeshifter (talk) 13:04, 10 November 2014 (UTC)[reply]

I think I see what you are trying to do, DePiep. I reworded the section and incorporated most of your wording. I shortened it and removed more of the warning tone. People now have more freedom to choose. --Timeshifter (talk) 13:26, 10 November 2014 (UTC)[reply]
Wholesale changes can be an improvement too. Being wholesale is not a reason to dismiss it.
Now, the section was not written as a help section at all. It kept repeating possible problems with rowspans and say "don't do it". That is not the topic of this page. Just note that these problems mainly exist for rowspan alone, with or without sorting. Also, the text was not a "help". And the advice to avoid rowspans always plus when sorting may be outdated because table sorting has improved enough. In short: if you build a good rowspanned table, you can add sorting.
What I wrote, and what I or any other editor expects to find here, is: if you have you rowsort OK, you can set it sortable. Not more complicated. (Must say that HELP:TABLE is not as complete on rowsort as I'd expect). Now I'll go read your edit. -DePiep (talk) 14:07, 10 November 2014 (UTC)[reply]
I removed again your copmplaints about rowspan being difficult. That is not the topic. And it is not even true. This is helptext: If you need rowspan, use rowspan. You can even sort it. -DePiep (talk) 14:12, 10 November 2014 (UTC)[reply]

Cleanup

I am performing some technical cleanup. Some issues:

  • Auto-ranking or adding a row numbering column (1,2,3) next to a table
    • Has links to user subpages
  • Default data type of a column
    • Contains: "proposed internationalisation: in German etc., treat comma as a decimal point" which makes no sense to me in its context

--  Gadget850 talk 13:21, 10 November 2014 (UTC)[reply]

I don't know anything about the German stuff. As for the linking to user pages, if it was prohibited on help pages the bots would have removed it long ago. They do so on article pages. I link to user sandbox pages from many talk pages. People use external links in the body of help pages, and not in reference format. Can help pages have subpages? If so, the row number columns can be moved there. --Timeshifter (talk) 13:33, 10 November 2014 (UTC)[reply]
Yes, subpages are enabled in the Help subspace. I don't know that there is a specific prohibition, but it is not a good idea. --  Gadget850 talk 14:24, 10 November 2014 (UTC)[reply]