• Home
  • Random
  • Recent changes
  • Special pages
  • Settings
  • About MOASSpedia
  • Disclaimers
MOASSpedia
  • 216.73.216.154
  • Talk
  • Watchlist
  • Contributions
  • Log in

Template:Static row numbers

Template Discussion
  • Language
  • Watch
  • History
  • Edit
    • Page information
    • Permanent link
    • What links here
Template documentation[view] [edit] [history] [purge]
CSSThis template uses TemplateStyles:
  • Template:Static row numbers/styles.css
Note: Category:Articles with tables with fixed row numbers uses a deprecated template. Please replace it with {{Static row numbers}}.

Template to automatically add row numbers to sortable tables. The row numbers will not be sorted when columns of data are sorted. A possible note to add above a table: {{noprint|'''''Row numbers''' are static. Other columns are sortable. This allows ranking of any column.''}}

These templates work together and make table formatting fast:

  • {{Static row numbers table}}
  • {{Static row numbers header}}
  • {{Static row numbers arrows}}
  • {{Static row numbers total}}

Some are used together here: List of U.S. states and territories by incarceration and correctional supervision rate

Contents

  • 1 Usage with wikitable and sortable
  • 2 Usage with sortable
  • 3 Usage with no other classes
  • 4 Using static-row-header-text to add a "No." column header
  • 5 Using static-row-header-hash to add a hash ("#") column header
  • 6 Marking additional header and footer rows with static-row-header
  • 7 Marking footer or header rows that also contain data cells (non-header cells)
  • 8 White background for data cells

Usage with wikitable and sortable

Place template before table where the automatic row numbers are required. Add class static-row-numbers to the table wikitext, as in the following example. It adds an unsorted column of row numbers.

With wikitable and sortable
Name Number Another Number
A 10 1000
B 50 800
C 100 150
D 20 700
E 70 350
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers"
! Name !! Number !! Another Number
|-
| A || 10 || 1000
|-
| B || 50 || 800
|-
| C || 100 || 150
|-
| D || 20 || 700
|-
| E || 70 || 350
|}

Usage with sortable

With sortable
Name Number Another Number
A 10 1000
B 50 800
C 100 150
D 20 700
E 70 350
{{Static row numbers}}
{| class="sortable static-row-numbers"
! Name !! Number !! Another Number
|-
| A || 10 || 1000
|-
| B || 50 || 800
|-
| C || 100 || 150
|-
| D || 20 || 700
|-
| E || 70 || 350
|}

Usage with no other classes

While designed to provide a static row number for sortable tables, it can be used just to add an automatic row number to plain tables.

With no other classes
Name Number Another Number
A 10 1000
B 50 800
C 100 150
D 20 700
E 70 350
{{Static row numbers}}
{| class="static-row-numbers"
! Name !! Number !! Another Number
|-
| A || 10 || 1000
|-
| B || 50 || 800
|-
| C || 100 || 150
|-
| D || 20 || 700
|-
| E || 70 || 350
|}

Using static-row-header-text to add a "No." column header

This adds a "No." as the row number column header.

With static-row-header-text to add a column header
Name Number Another Number
A 10 1000
B 50 800
C 100 150
D 20 700
E 70 350
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers static-row-header-text"
! Name !! Number !! Another Number
|-
| A || 10 || 1000
|-
| B || 50 || 800
|-
| C || 100 || 150
|-
| D || 20 || 700
|-
| E || 70 || 350
|}

Using static-row-header-hash to add a hash ("#") column header

This adds a hash ("#") as the row number column header.

With static-row-header-hash to add a column header
Name Number Another Number
A 10 1000
B 50 800
C 100 150
D 20 700
E 70 350
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers static-row-header-hash"
! Name !! Number !! Another Number
|-
| A || 10 || 1000
|-
| B || 50 || 800
|-
| C || 100 || 150
|-
| D || 20 || 700
|-
| E || 70 || 350
|}

Marking additional header and footer rows with static-row-header

The class static-row-header is added to additional header rows (other than the first one). It prevents those header rows from having row numbers. It also prevents them from being sorted. It is important to add this class for consistent appearance in different Wikipedia skins and views. It is necessary for correct numbering in the minerva skin on mobile view which renders HTML tables differently.

Marking additional header and footer rows with static-row-header
Name Number Another Number
(unit) (per capita)
A 10 1000
B 50 800
C 100 150
D 20 700
E 70 350
Totals 250 3000
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers"
! Name !! Number !! Another Number
|- class="static-row-header"
!  !! (unit) !! (per capita)
|-
| A || 10 || 1000
|-
| B || 50 || 800
|-
| C || 100 || 150
|-
| D || 20 || 700
|-
| E || 70 || 350
|- class="static-row-header"
! Totals !! 250 !! 3000
|}

Marking footer or header rows that also contain data cells (non-header cells)

To prevent them from sorting class=sorttop or class=sortbottom must also be added. For an example of header rows like this see this version of the 2021 table in this list article.

Marking footer or header rows that also contain data cells (non-header cells)
Name Number Another Number
(unit) (per capita)
A 10 1000
B 50 800
C 100 150
D 20 700
E 70 350
Totals 250 3000
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers"
! Name !! Number !! Another Number
|- class="static-row-header"
!  !! (unit) !! (per capita)
|-
| A || 10 || 1000
|-
| B || 50 || 800
|-
| C || 100 || 150
|-
| D || 20 || 700
|-
| E || 70 || 350
|- class="sortbottom static-row-header"
! Totals 
|| 250 || 3000
|}

White background for data cells

Add class=srn-white-background to the top line of the table wikitext. It can be used on tables with inline cell or row background colors. Neither are affected by this class.

This class is unnecessary if you are using this:

  • {{Static row numbers table}}

The class is incorporated into that template.

White background for data cells
1 2 3
1-1 2-1 3-1
1-2 2-2 3-2
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers srn-white-background"
|-
! 1 !! 2 !! 3
|-
| 1-1 || 2-1 || 3-1
|-
| 1-2 || 2-2 || 3-2
|}
The above documentation is transcluded from Template:Static row numbers/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://moasspedia.org/w/index.php?title=Template:Static_row_numbers&oldid=31634"
Categories:
  • Templates using TemplateStyles
  • Table templates
Last edited on 19 September 2021, at 13:00

MOASSpedia

Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • This page was last edited on 19 September 2021, at 13:00.
  • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • Privacy policy
  • About MOASSpedia
  • Disclaimers
  • Desktop