Changes

Help:Tables

3,484 bytes added, 17:11, 17 May 2007
Classes: Added info on Sortable tables.
|}
The "wikitable" clsss is generally the preferred format for most charts, though "greylapse" is also acceptable in cases where space is a premium, as it uses slightly less space. The "toc" class is usually reserved for creating a custom Table of Contents on pages where the default Table of Contents is not wanted.
 
===Sortable Tables===
Another set of tables can be used which allows you to make tables sortable by the values in the columns. They are "sortable", "wikitable sortable", "greylapse sortable", and "toc sortable". Note that for the latter three, you will need to put quotes around the class-name, since they are now two words.
{|
|-valign=top
|
<nowiki>{|class=sortable</nowiki>
<nowiki>!Name!!Value!!Price</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Alpha||42||$500.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Beta||27||$2000.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Gamma||3||$10.00</nowiki>
<nowiki>|}</nowiki>
|
<nowiki>{| class="wikitable sortable"</nowiki>
<nowiki>!Name!!Value!!Price</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Alpha||42||$500.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Beta||27||$2000.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Gamma||3||$10.00</nowiki>
<nowiki>|}</nowiki>
|
<nowiki>{| class="greylapse sortable"</nowiki>
<nowiki>!Name!!Value!!Price</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Alpha||42||$500.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Beta||27||$2000.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Gamma||3||$10.00</nowiki>
<nowiki>|}</nowiki>
|
<nowiki>{| class="toc sortable"</nowiki>
<nowiki>!Name!!Value!!Price</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Alpha||42||$500.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Beta||27||$2000.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Gamma||3||$10.00</nowiki>
<nowiki>|}</nowiki>
|-
|
{|class=sortable
!Name!!Value!!Price
|-
|Alpha||42||$500.00
|-
|Beta||27||$2000.00
|-
|Gamma||3||$10.00
|}
|
{| class="wikitable sortable"
!Name!!Value!!Price
|-
|Alpha||42||$500.00
|-
|Beta||27||$2000.00
|-
|Gamma||3||$10.00
|}
|
{| class="greylapse sortable"
!Name!!Value!!Price
|-
|Alpha||42||$500.00
|-
|Beta||27||$2000.00
|-
|Gamma||3||$10.00
|}
|
{| class="toc sortable"
!Name!!Value!!Price
|-
|Alpha||42||$500.00
|-
|Beta||27||$2000.00
|-
|Gamma||3||$10.00
|}
|}
 
You can exlcude a column from sorting by giving the header the "unsortable" class, like so:
{|
|
<nowiki>{| class="wikitable sortable"</nowiki>
<nowiki>!Name!!Value!!Price!!class=unsortable|Notes</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Alpha||42||$500.00||Found under the bed</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Beta||27||$2000.00||Hiding in the closet</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Gamma||3||$10.00||Above the dresser</nowiki>
<nowiki>|}</nowiki>
|-
|
{| class="wikitable sortable"
!Name!!Value!!Price!!class=unsortable|Notes
|-
|Alpha||42||$500.00||Found under the bed
|-
|Beta||27||$2000.00||Hiding in the closet
|-
|Gamma||3||$10.00||Above the dresser
|}
|}
 
You can also exclude a bottom row from sorting by giving it the "sortbottom" class:
 
{|
|
<nowiki>{| class="wikitable sortable"</nowiki>
<nowiki>!Name!!Value!!Price</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Alpha||42||$500.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Beta||27||$2000.00</nowiki>
<nowiki>|-</nowiki>
<nowiki>|Gamma||3||$10.00</nowiki>
<nowiki>|-class="sortbottom"</nowiki>
<nowiki>|'''Totals:'''||'''72'''||'''$2510'''</nowiki>
<nowiki>|}</nowiki>
|-
{| class="wikitable sortable"
!Name!!Value!!Price
|-
|Alpha||42||$500.00
|-
|Beta||27||$2000.00
|-
|Gamma||3||$10.00
|-class="sortbottom"
|'''Totals:'''||'''72'''||'''$2510.00'''
|}
|}
Keep in mind that only ''one'' row can be bottom-sorted in this way, and there is no way to top-sort a column. Also, tables with row-spanning or column-spanning cells may not behave properly as sortable tables.
 
==TD==