Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Problem with class=sorttop  





2 Solution for single row header  





3 Solution for single row header. Narrower table  














User:Timeshifter/Sandbox228

















User page
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
User contributions
User logs
View user groups
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 

< User:Timeshifter

Problem with class=sorttop

[edit]

class=sorttop rows can become part of the sticky header. This only happens after sorting.

This table excerpt is adapted from the 2021 tableinthis versionofCOVID-19 pandemic deaths#2021 (first half).

The static rows at the top under the main header row are rows of data that shouldn't sort, and shouldn't have row numbers.

class=static-row-header prevents row numbers on those rows.
class=sorttop prevents the row from sorting.

See the yellow highlighted lines in the wikitext below.

{{mw-datatable}}{{static row numbers}}{{sticky header}}{{table alignment}}
{| class="wikitable sortable mw-datatable static-row-numbers sticky-header col1left col2left" style=text-align:right;
|+Cumulative COVID-19 deaths at the start of each month in 2021
!Date!!First case!!Jan&nbsp;1!!Feb&nbsp;1!!Mar&nbsp;1!!Apr&nbsp;1!!May&nbsp;1!!Jun&nbsp;1
|- class="sorttop static-row-header"
|World || ||1,472,363||1,786,759||2,021,136||2,262,948||2,603,854||3,663,570
|- class="sorttop static-row-header"
|Days to double || ||112||105||113||130||143||154
|- class="sorttop static-row-header"
|Countries and territories || ||196||202||202||205||206||209
|-
...

Solution for single row header

[edit]

This solution only works for a single row header. The number of lines in that row does not matter. This does not work for multi-row headers.

The solution is to use class=sticky instead of class=sticky-header

class=sticky goes in a different part of the wikitext.

See the yellow highlighted line in the wikitext below.

Cumulative COVID-19 deaths at the start of each month in 2021
Date First case Jan 1 Feb 1 Mar 1 Apr 1 May 1 Jun 1
World 1,472,363 1,786,759 2,021,136 2,262,948 2,603,854 3,663,570
Days to double 112 105 113 130 143 154
Countries and territories 196 202 202 205 206 209
 USA March 3, 2020 335,789 436,051 508,584 545,887 569,722 588,756
 Brazil March 19, 2020 193,875 223,945 254,221 317,646 401,186 461,931
 India March 13, 2020 148,994 154,392 157,157 162,927 211,853 331,895
{{mw-datatable}}{{static row numbers}}{{sticky header}}{{table alignment}}
{| class="wikitable sortable mw-datatable static-row-numbers col1left col2left" style=text-align:right;
|+Cumulative COVID-19 deaths at the start of each month in 2021
|- class=sticky
!Date!!First case!!Jan&nbsp;1!!Feb&nbsp;1!!Mar&nbsp;1!!Apr&nbsp;1!!May&nbsp;1!!Jun&nbsp;1
...
|}

Solution for single row header. Narrower table

[edit]

See: User:Timeshifter/Sandbox233. A place to test if it works without a wider table on the page.

Cumulative COVID-19 deaths at the start of each month in 2021
Date First case Jan 1
World 1,472,363
Days to double 112
Countries and territories 196
 USA March 3, 2020 335,789
 Brazil March 19, 2020 193,875
 India March 13, 2020 148,994
{{mw-datatable}}{{static row numbers}}{{sticky header}}{{table alignment}}
{| class="wikitable sortable mw-datatable static-row-numbers col1left col2left" style=text-align:right;
|+Cumulative COVID-19 deaths at the start of each month in 2021
|- class=sticky
!Date!!First case!!Jan&nbsp;1
...
|}

For portrait view on cell phones:

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

Retrieved from "https://en.wikipedia.org/w/index.php?title=User:Timeshifter/Sandbox228&oldid=1188166971"





This page was last edited on 3 December 2023, at 19:14 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki