Template:Static row numbers/doc

Template page

This category is an index of templates which use TemplateStyles. It is automatically populated by {{Uses TemplateStyles}}.


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="static-row-numbers"

These templates are helpful for non-header rows:

These templates are deprecated:

Usage with wikitable and sortable

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"
|- 
! 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.

Name Data columns
A B C
Red 1 2 3
Lime 4 5 6
Gold 7 8 9
Totals 12 15 18
{{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
|- class="sortbottom static-row-header"
| '''Totals''' || 12 || 15 || 18
|}

White background on data cells

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.

Name Data columns
A B C
Red 1 2 3
Lime 4 5 6
Gold 7 8 9
Totals 12 15 18
{{Static row numbers}}
{| class="wikitable sortable static-row-numbers srn-white-background"
|-
! rowspan=2 | Name
! colspan=3 | Data columns
|-
! A !! B !! C
|-
| Red || 1|| 2 || style=background:palegreen |3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|- class="sortbottom static-row-header" style=background:yellow
| '''Totals''' || 12 || 15 || 18
|}

Redirects

See also

  • {{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.