Content deleted Content added
c/e |
|||
Line 342:
|}
==
=== Vertical headers ===
Line 401:
</syntaxhighlight></div>
<div style="display:inline-table; border: 2px solid lime; padding: 0.5em;">
Line 490:
== Creating sortable tables ==
[[File:Wikipedia VisualEditor Table Properties.png|thumb|The properties panel of a table in VisualEditor allows you to mark a table as sortable.]]
If you are using the [[Wikipedia:VisualEditor|Visual
=== Simple example ===
This is the
<syntaxhighlight lang="wikitext">
{| class="wikitable sortable"
Line 516:
|}
</syntaxhighlight>
The <code>!</code> indicates cells that are header cells. In order for a table to be sortable, the first row(s) of a table need to be entirely made up out of these header cells. You can learn more about the basic table syntax by taking the [[Help:Table/Introduction to tables|Introduction to tables]] for source editing.
=== Initial sort order of rows ===
When users are first presented with a table, the rows will always appear in the same order as in the wikitext. If you want a table to appear sorted by a certain column, you must sort the wikitext itself in that order. This is usually done for the first column. The
== Restrictions and exclusions ==
Tables can only
=== Making selected columns unsortable ===
Line 708:
{{See|meta:Help:Sorting#Forcing the sort mode for a column}}
The <code>data-sort-type="..."</code> attribute can be added inside the header of a column to ensure that the cells underneath are ''all'' treated as a specified type of data. {{A note|It must go in the header cell with the sorting icon}}. It will not work in a header cell without a sorting icon. For example; when there are two rows of headers, the bottom row will always have the sorting icons, as explained previously.
The following (case-insensitive) values are valid for <code>data-sort-type</code>:
Line 813:
Without <code>data-sort-type=text</code> in the header, the tablesorter gets confused by the numeric titles in the first few rows into treating the entire column as numeric. This results in it wrongly sorting the non-numeric titles as zero regardless of the alphabetical ordering of their text.
Note that if a column without declared sort-type contains only numeric values within the first top
=== Default data type of a column ===
Line 837:
The sort mode is determined by the first 5 non-blank rows below the header after loading the page. This can also change after deleting a row, or adding a column. Therefore, it is wise to make sure that every element matches the criterion for the required data type. Using a [[Help:Table#Row template|row template]] this can be done very conveniently.
The method of making sure the sort mode of each column is as desired, is specify a <code>data-sort-type</code>, see [[#Forcing a column to have a particular data type|
== Specifying a sort key for a cell ==
|