الگو:Static row numbers/توضیحات: تفاوت میان نسخهها
(صفحهای تازه حاوی «{{زیرصفحه توضیحات}} <!-- لطفاً ردهها را جایی که در پایین این صفحه اشاره شدهاست قرار دهید و میانویکیها را هم در ویکیداده (ویکیپدیا:ویکیداده را ببینید) --> Template:Static row numbers/styles.css == استفاده == الگو برای ردیف گذاری اتوماتیک سطر جدول== Usage wit...» ایجاد کرد) |
بدون خلاصۀ ویرایش |
||
خط ۱: | خط ۱: | ||
{{ | {{Documentation subpage}} | ||
<!-- | <!-- Add categories where indicated at the bottom of this page and interwikis at Wikidata --> | ||
{{Template redirect||static-row-numbers}} | |||
{{Uses TemplateStyles|Template:Static row numbers/styles.css}} | |||
This template adds a column of row numbers to a table. The numbers do not sort with the rest of the table, remaining static. Optional classes are provided to display a column label or disable numbers on specific rows. | |||
{| style=" | It works on desktop and mobile versions of Wikipedia pages. | ||
|+ | |||
== Usage == | |||
Include this template by adding {{tlc|static row numbers}} or its redirect {{tlc|static-row-numbers}} above a table. Add the <code>static-row-numbers</code> class to the table start wikitext. Optionally add the other classes listed below. | |||
<div style="display: inline-grid;"> | |||
'''Wikitext:''' | |||
<syntaxhighlight lang=wikitext> | |||
{{static row numbers}} | |||
{| class="static-row-numbers" | |||
</syntaxhighlight> | |||
</div> | |||
{| class="wikitable" style="background-color: white;" | |||
|+ Classes for table start wikitext: <code><nowiki>{|</nowiki> class="''class1 class2''"</code>. | |||
|- | |||
! Table class | |||
! Summary | |||
|- | |||
| class="nowrap" | <code>static-row-numbers</code> | |||
| '''Required.''' Displays a column of row numbers. Requires at least one header row. | |||
|- | |||
| class="nowrap" | <code>static-row-header-text</code> | |||
| Displays "No." text in column label. | |||
|- | |||
| class="nowrap" | <code>static-row-header-hash</code> | |||
| Displays hash ("#") symbol in column label. | |||
|} | |||
{| class="wikitable" style="background-color: white;" | |||
|+ Classes for row wikitext: <code><nowiki>|-</nowiki> class="''class1 class2''"</code>. | |||
|- | |||
! Row class | |||
! Summary | |||
|- | |||
| class="nowrap" | <code>static-row-header</code> | |||
| Disables a row number. Disables borders between consecutive row usages (simulates <code>rowspan</code>). Add to <code>sorttop</code> and <code>sortbottom</code> rows. Add to header rows except the first. | |||
|- | |||
| class="nowrap" | <code>static-row-numbers-norank</code> | |||
| Disables a row number. Maintains borders between consecutive row usages. Optionally add to data rows. | |||
|} | |||
== Used with sortable == | |||
Multiple header rows in a sortable table should have the <code>static-row-header</code> class added to all header rows except the first one so that they are not numbered when JavaScript is disabled. It is also needed on rows that use the <code>sorttop</code> or <code>sortbottom</code> class, described at [[#Disable number on specific rows]]. | |||
<div style="display: inline-grid;"> | |||
'''Wikitext:''' | |||
<syntaxhighlight lang="wikitext" highlight=1-2,6,14,16> | |||
{{static row numbers}} | |||
{| class="wikitable sortable static-row-numbers" | |||
|- | |- | ||
| | ! rowspan="2" | Color | ||
{{ | ! colspan="3" | Data | ||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |||
| Red || 1 || 2 || 3 | |||
|- | |||
| Lime || 4 || 5 || 6 | |||
|- | |||
| Gold || 7 || 8 || 9 | |||
|- class="sortbottom static-row-header" | |||
| '''Total''' || 12 || 15 || 18 | |||
|- class="sortbottom static-row-header" | |||
| '''Average''' || 4 || 5 || 6 | |||
|} | |||
</syntaxhighlight> | |||
</div> | |||
<div style="display: inline-grid;"> | |||
'''Produces:''' | |||
{{static row numbers}} | |||
{| class="wikitable sortable static-row-numbers" | {| class="wikitable sortable static-row-numbers" | ||
|- | |- | ||
| A || | ! rowspan="2" | Color | ||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |||
| Red || 1 || 2 || 3 | |||
|- | |||
| Lime || 4 || 5 || 6 | |||
|- | |- | ||
| | | Gold || 7 || 8 || 9 | ||
|- class="sortbottom static-row-header" | |||
| '''Total''' || 12 || 15 || 18 | |||
|- class="sortbottom static-row-header" | |||
| '''Average''' || 4 || 5 || 6 | |||
|} | |||
</div> | |||
== Used without sortable == | |||
Multiple header rows in a non-sortable table should have the <code>static-row-header</code> class added to all header rows except the first one, described at [[#Disable number on specific rows]]. | |||
<div style="display: inline-grid;"> | |||
'''Wikitext:''' | |||
<syntaxhighlight lang="wikitext" highlight=1-2,6> | |||
{{static row numbers}} | |||
{| class="wikitable static-row-numbers" | |||
|- | |- | ||
| | ! rowspan="2" | Color | ||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |- | ||
| | | Red || 1 || 2 || 3 | ||
|- | |- | ||
| | | Lime || 4 || 5 || 6 | ||
|- | |||
| Gold || 7 || 8 || 9 | |||
|} | |} | ||
| | </syntaxhighlight> | ||
<syntaxhighlight lang= | </div> | ||
{{ | |||
{| class="wikitable | <div style="display: inline-grid;"> | ||
! | '''Produces:''' | ||
{{static row numbers}} | |||
{| class="wikitable static-row-numbers" | |||
|- | |||
! rowspan="2" | Color | |||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |||
| Red || 1 || 2 || 3 | |||
|- | |||
| Lime || 4 || 5 || 6 | |||
|- | |||
| Gold || 7 || 8 || 9 | |||
|} | |||
</div> | |||
== Display "No." text in column label == | |||
To display the "No." text in the number column's header (label), add the <code>static-row-header-text</code> class to the table start wikitext. | |||
<div style="display: inline-grid;"> | |||
'''Wikitext:''' | |||
<syntaxhighlight lang="wikitext" highlight=1-2,6> | |||
{{static row numbers}} | |||
{| class="wikitable static-row-numbers static-row-header-text" | |||
|- | |||
! rowspan="2" | Color | |||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |- | ||
| | ... | ||
</syntaxhighlight> | |||
</div> | |||
<div style="display: inline-grid;"> | |||
'''Produces:''' | |||
{{static row numbers}} | |||
{| class="wikitable static-row-numbers static-row-header-text" | |||
|- | |- | ||
| | ! rowspan="2" | Color | ||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |- | ||
| | | Red || 1 || 2 || 3 | ||
|- | |- | ||
| | | Lime || 4 || 5 || 6 | ||
|- | |- | ||
| | | Gold || 7 || 8 || 9 | ||
|} | |} | ||
</div> | |||
== Display hash ("#") symbol in column label == | |||
To display a hash ("#") symbol in the number column's header (label), add the <code>static-row-header-hash</code> class to the table start wikitext. | |||
<div style="display: inline-grid;"> | |||
'''Wikitext:''' | |||
<syntaxhighlight lang="wikitext" highlight=1-2,6> | |||
{{static row numbers}} | |||
{| class="wikitable static-row-numbers static-row-header-hash" | |||
|- | |||
! rowspan="2" | Color | |||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |||
... | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</div> | |||
<div style="display: inline-grid;"> | |||
'''Produces:''' | |||
{{static row numbers}} | |||
{| class="wikitable static-row-numbers static-row-header-hash" | |||
|- | |||
! rowspan="2" | Color | |||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- | |||
| Red || 1 || 2 || 3 | |||
|- | |||
| Lime || 4 || 5 || 6 | |||
|- | |||
| Gold || 7 || 8 || 9 | |||
|} | |} | ||
</div> | |||
== Disable number on specific rows == | |||
< | This section details how to disable numbers on specific rows by adding either the <code>static-row-numbers-norank</code> or <code>static-row-header</code> class to the row wikitext. | ||
}}</ | The <code>static-row-numbers-norank</code> class can be added to data rows to disable the number. | ||
The <code>static-row-header</code> class disables the number and border between other rows that use this class consecutively, simulating a <code>rowspan</code> (see [[Help:Table#Colspan and rowspan]]). It should be added to: | |||
* Header rows excluding the first. For sortable tables, it prevents numbering when JavaScript is disabled. | |||
* Rows using the <code>sorttop</code> or <code>sortbottom</code> class. | |||
Note, the <code>sorttop</code> or <code>sortbottom</code> class is added to a row so it stays at the top or bottom of a sorted list, per [[Help:Sortable tables]]. | |||
<div style="display: inline-grid;"> | |||
'''Wikitext:''' | |||
<syntaxhighlight lang="wikitext" highlight=1-2,6,8,10,14,16,20,22> | |||
{{static row numbers}} | |||
{| class="wikitable sortable static-row-numbers" | |||
|- | |||
! rowspan="2" | Color | |||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- class="sorttop static-row-header" | |||
| '''Min''' || 1 || 2 || 3 | |||
|- class="sorttop static-row-header" | |||
| '''Max''' || 10 || 11 || 12 | |||
|- | |||
| Red || 1 || 2 || 3 | |||
|- class="static-row-numbers-norank" | |||
| Lime || 4 || 5 || 6 | |||
|- class="static-row-numbers-norank" | |||
| Gold || 7 || 8 || 9 | |||
|- | |||
| Blue || 10 || 11 || 12 | |||
|- class="sortbottom static-row-header" | |||
| '''Total''' || 22 || 26 || 30 | |||
|- class="sortbottom static-row-header" | |||
| '''Average''' || 5.5 || 6.5 || 7.5 | |||
|} | |||
</syntaxhighlight> | |||
</div> | |||
<div style="display: inline-grid;"> | |||
'''Produces:''' | |||
{{static row numbers}} | |||
{| class="wikitable sortable static-row-numbers" | |||
|- | |||
! rowspan="2" | Color | |||
! colspan="3" | Data | |||
|- class="static-row-header" | |||
! A !! B !! C | |||
|- class="sorttop static-row-header" | |||
| '''Min''' || 1 || 2 || 3 | |||
|- class="sorttop static-row-header" | |||
| '''Max''' || 10 || 11 || 12 | |||
|- | |||
| Red || 1 || 2 || 3 | |||
|- class="static-row-numbers-norank" | |||
| Lime || 4 || 5 || 6 | |||
|- class="static-row-numbers-norank" | |||
| Gold || 7 || 8 || 9 | |||
|- | |||
| Blue || 10 || 11 || 12 | |||
|- class="sortbottom static-row-header" | |||
| '''Total''' || 22 || 26 || 30 | |||
|- class="sortbottom static-row-header" | |||
| '''Average''' || 5.5 || 6.5 || 7.5 | |||
|} | |||
</div> |
نسخهٔ ۲۴ مهٔ ۲۰۲۴، ساعت ۰۲:۰۹
این زیرصفحهٔ مستندات الگو:Static row numbers است. این شامل اطلاعات استفاده، الگوها، پیوندهای بین زبانی و سایر اطلاعات است که در اصل الگو صفحه قرار نمیگیرد. |
الگو:Template redirect خطای لوآ در پودمان:TNT در خط 159: افزونهٔ JsonConfig ناموجود است؛ ناتوان در بارگیری https://commons.wikimedia.org/wiki/Data:I18n/Uses TemplateStyles.tab.
This template adds a column of row numbers to a table. The numbers do not sort with the rest of the table, remaining static. Optional classes are provided to display a column label or disable numbers on specific rows.
It works on desktop and mobile versions of Wikipedia pages.
Usage
Include this template by adding {{static row numbers}}
or its redirect {{static-row-numbers}}
above a table. Add the static-row-numbers
class to the table start wikitext. Optionally add the other classes listed below.
Wikitext:
{{static row numbers}}
{| class="static-row-numbers"
Table class | Summary |
---|---|
static-row-numbers
|
Required. Displays a column of row numbers. Requires at least one header row. |
static-row-header-text
|
Displays "No." text in column label. |
static-row-header-hash
|
Displays hash ("#") symbol in column label. |
Row class | Summary |
---|---|
static-row-header
|
Disables a row number. Disables borders between consecutive row usages (simulates rowspan ). Add to sorttop and sortbottom rows. Add to header rows except the first.
|
static-row-numbers-norank
|
Disables a row number. Maintains borders between consecutive row usages. Optionally add to data rows. |
Used with sortable
Multiple header rows in a sortable table should have the static-row-header
class added to all header rows except the first one so that they are not numbered when JavaScript is disabled. It is also needed on rows that use the sorttop
or sortbottom
class, described at #Disable number on specific rows.
Wikitext:
{{static row numbers}}
{| class="wikitable sortable static-row-numbers"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
| Red || 1 || 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|- class="sortbottom static-row-header"
| '''Total''' || 12 || 15 || 18
|- class="sortbottom static-row-header"
| '''Average''' || 4 || 5 || 6
|}
Produces:
Color | Data | ||
---|---|---|---|
A | B | C | |
Red | 1 | 2 | 3 |
Lime | 4 | 5 | 6 |
Gold | 7 | 8 | 9 |
Total | 12 | 15 | 18 |
Average | 4 | 5 | 6 |
Used without sortable
Multiple header rows in a non-sortable table should have the static-row-header
class added to all header rows except the first one, described at #Disable number on specific rows.
Wikitext:
{{static row numbers}}
{| class="wikitable static-row-numbers"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
| Red || 1 || 2 || 3
|-
| Lime || 4 || 5 || 6
|-
| Gold || 7 || 8 || 9
|}
Produces:
Color | Data | ||
---|---|---|---|
A | B | C | |
Red | 1 | 2 | 3 |
Lime | 4 | 5 | 6 |
Gold | 7 | 8 | 9 |
Display "No." text in column label
To display the "No." text in the number column's header (label), add the static-row-header-text
class to the table start wikitext.
Wikitext:
{{static row numbers}}
{| class="wikitable static-row-numbers static-row-header-text"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
...
Produces:
Color | Data | ||
---|---|---|---|
A | B | C | |
Red | 1 | 2 | 3 |
Lime | 4 | 5 | 6 |
Gold | 7 | 8 | 9 |
Display hash ("#") symbol in column label
To display a hash ("#") symbol in the number column's header (label), add the static-row-header-hash
class to the table start wikitext.
Wikitext:
{{static row numbers}}
{| class="wikitable static-row-numbers static-row-header-hash"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|-
...
Produces:
Color | Data | ||
---|---|---|---|
A | B | C | |
Red | 1 | 2 | 3 |
Lime | 4 | 5 | 6 |
Gold | 7 | 8 | 9 |
Disable number on specific rows
This section details how to disable numbers on specific rows by adding either the static-row-numbers-norank
or static-row-header
class to the row wikitext.
The static-row-numbers-norank
class can be added to data rows to disable the number.
The static-row-header
class disables the number and border between other rows that use this class consecutively, simulating a rowspan
(see Help:Table#Colspan and rowspan). It should be added to:
- Header rows excluding the first. For sortable tables, it prevents numbering when JavaScript is disabled.
- Rows using the
sorttop
orsortbottom
class.
Note, the sorttop
or sortbottom
class is added to a row so it stays at the top or bottom of a sorted list, per Help:Sortable tables.
Wikitext:
{{static row numbers}}
{| class="wikitable sortable static-row-numbers"
|-
! rowspan="2" | Color
! colspan="3" | Data
|- class="static-row-header"
! A !! B !! C
|- class="sorttop static-row-header"
| '''Min''' || 1 || 2 || 3
|- class="sorttop static-row-header"
| '''Max''' || 10 || 11 || 12
|-
| Red || 1 || 2 || 3
|- class="static-row-numbers-norank"
| Lime || 4 || 5 || 6
|- class="static-row-numbers-norank"
| Gold || 7 || 8 || 9
|-
| Blue || 10 || 11 || 12
|- class="sortbottom static-row-header"
| '''Total''' || 22 || 26 || 30
|- class="sortbottom static-row-header"
| '''Average''' || 5.5 || 6.5 || 7.5
|}
Produces:
Color | Data | ||
---|---|---|---|
A | B | C | |
Min | 1 | 2 | 3 |
Max | 10 | 11 | 12 |
Red | 1 | 2 | 3 |
Lime | 4 | 5 | 6 |
Gold | 7 | 8 | 9 |
Blue | 10 | 11 | 12 |
Total | 22 | 26 | 30 |
Average | 5.5 | 6.5 | 7.5 |