Template to automatically add an unsortable column of row numbers to tables. A possible note to add above a sortable table: Row numbers are static. Other columns are sortable. This allows ranking of any column.
Works with wikitable, sortable, and plain tables. Include this template before the table and add the class static-row-numbers to the table wikitext.
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers"
|-
! rowspan=2 | Name
! colspan=3 | Data columns
|-
! A !! B !! C
|-
| Red || 1|| 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
Usage with wikitable
It requires at least one row of column headers. For multiple rows of headers, add class static-row-header to the row wikitext to disable numbering and remove the shared border; not needed if only one row of headers.
Name
Data columns
A
B
C
Red
1
2
3
Lime
4
5
6
Gold
7
8
9
{{Static row numbers}}
{| class="wikitable static-row-numbers"
|- class=static-row-header
! rowspan=2 | Name
! colspan=3 | Data columns
|- class=static-row-header
! A !! B !! C
|-
| Red || 1|| 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
Usage with sortable
Name
Data columns
A
B
C
Red
1
2
3
Lime
4
5
6
Gold
7
8
9
{{Static row numbers}}
{| class="sortable static-row-numbers"
|-
! rowspan=2 | Name
! colspan=3 | Data columns
|-
! A !! B !! C
|-
| Red || 1|| 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
Usage with plain tables
It requires at least one row of column headers. For multiple rows of headers, add class static-row-header to the row wikitext to disable numbering; not needed if only one row of headers.
Name
Data columns
A
B
C
Red
1
2
3
Lime
4
5
6
Gold
7
8
9
{{Static row numbers}}
{| class="static-row-numbers"
|-
! rowspan=2 | Name
! colspan=3 | Data columns
|- class=static-row-header
! A !! B !! C
|-
| Red || 1|| 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
Add "No." column header
This adds the No. text as the number column header text. Add class static-row-header-text to the table wikitext.
Name
Data columns
A
B
C
Red
1
2
3
Lime
4
5
6
Gold
7
8
9
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers static-row-header-text"
|-
! rowspan=2 | Name
! colspan=3 | Data columns
|-
! A !! B !! C
|-
| Red || 1|| 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
Add hash ("#") column header
This adds the hash (#) symbol as the number column header text. Add class static-row-header-hash to the table wikitext.
Name
Data columns
A
B
C
Red
1
2
3
Lime
4
5
6
Gold
7
8
9
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers static-row-header-hash"
|-
! rowspan=2 | Name
! colspan=3 | Data columns
|-
! A !! B !! C
|-
| Red || 1|| 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
No number on specific rows
This disables numbers on specific rows. Add class static-row-header to the row wikitext. To prevent rows from sorting, add classes sorttop and/or sortbottom. For more info, see Help:Sortable tables.
This adds a white background to data cells. Headers are unaffected. Add class srn-white-background to the table wikitext. You can set other background colors on specific rows or cells using inline styles. For more info, see Help:Table#Color; scope of parameters.
{{Sorting row}} - Adds a sorting row. It can't be used with data-sort-type=number, or any form of data-sort-type=VALUE, or it breaks sorting. See Help:Sortable tables.
{{mw-datatable}} - Another way to add a white background to data cells.