Template:Static row numbers/doc
![]() | This is a documentation subpage for Template:Static row numbers. It contains usage information, categories and other content or metadata that is not part of the original template. |
Introduction
This is a template copied from https://en.wikipedia.org/wiki/Template:Static_row_numbers that doesn't actually work here. It needs mw:Extension:TemplateStyles.
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 no rank}}
- {{Static row numbers total}}
Usage with wikitable
and sortable
Place template before table where the automatic row numbers are required. Add class static-row-numbers
to the table text, as in the following example. It adds an unsorted column of row numbers.
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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.
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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. Add class=static-row-header-text to the top line of the table text. It does not work with {{Static row numbers table}}.
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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.
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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
|}
|
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.
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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
|}
|
To prevent them from sorting class=sorttop
or class=sortbottom
must also be added.
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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 text. 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:
The class is incorporated into that template.
<templatestyles src="Template:Static row numbers/styles.css" />
|
{{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
|}
|
See also
- {{Sorting row}} - a way to add a sorting row with centered sorting icons without using any {{Static row numbers}} templates or sub-templates.