For faster navigation, this Iframe is preloading the Wikiwand page for Help:可排序表格.

Help:可排序表格

此條目可参照英語維基百科相應條目来扩充。 (2017年7月20日)若您熟悉来源语言和主题,请协助参考外语维基百科扩充条目。请勿直接提交机械翻译,也不要翻译不可靠、低品质内容。依版权协议,译文需在编辑摘要注明来源,或于讨论页顶部标记((Translated page))标签。

使用[编辑]

读者浏览维基百科时,可能会看到可排序的表格。可排序表格的标志是标题单元格标有箭头。将之点击就会让表格各行按所选列排序,初次点击为升序,之后点击就在降序和升序见来回切换。

实际的排序过程通过电脑的客户端JavaScript完成。也就是说,只有浏览器启用JavaScript时方能使用此功能。排序速度倚赖于电脑自身和数据量。速度慢的电脑排序超大表格,就会消耗不少时间。

示例

这是一个简易的可排序表格示例:

名字 数据 更多数据
273 53
65 8,492
耗子 1,649 548
物品 數量 價格
A 1 $123億
B 2 $4500萬
C 1 不適用
C 3 $3210億
總計: 7 $3333億

标题行复杂的表格

标题行复杂的表格如今也能正确排序。如:

名字 数据列 另一列
数据 更多数据
273 53 1
65 8,492 2
耗子 1,649 548 3

数据行复杂的表格

通过|rowspan=n,可将多行单元格合并。

使用rowspan时必须要指定行数,这是排序功能正常运作的前提。错误的rowspan会中断排序功能,显示错误的数据。在排序表格中,不能同时对内容单元格使用|rowspan=n colspan=m

下面给出几个例子。

正确填写rowspan数的排序表格:

名字 欢迎度 数据 更多数据 年份
流行宠物 273 53 2013
65 8,492 2014
耗子 1,649 548

注意在排序时,合并单元格会拆分开来,同时这些单元格都采用同一数据(比如“2014”)。

错误的rowspan数会中断排序功能,让行列混乱。

错误的rowspan会中断排序判定
名字 欢迎度 数据 更多数据 年份
流行宠物 273 53 2013
65 8,492 2014
耗子 1,649 548

在线表格编辑器和合并工具

wikitable.eu5.orgtablesgenerator是两个简易的表格编辑器。

在狭窄的空间中:新开一列显示排序开关

若让表格适应窄屏幕,可以在原标题文字下插入一行,显示排序开关。排序开关总是显示于最下方的标题单元格。

在任一空标题单元格填入<br />,不然排序行会非常窄。

名字 数据列 另一列
数据 更多数据

273 53 1
65 8,492 2
耗子 1,649 548 3
{| class="wikitable sortable"
|-
! rowspan="2" | 名字
! colspan="2" | 数据列
! rowspan="2" | 另一列
|-
! 数据
! 更多数据
|-
! <br>!! !! !!
|-
| 喵
| 273
| 53
| 1
|-
| 汪
| 65
| 8,492
| 2
|-
| 耗子
| 1,649
| 548
| 3
|}

參見[编辑]

{{bottomLinkPreText}} {{bottomLinkText}}
Help:可排序表格
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?