Table Attributes

Attributes are defined as a TABLEPLUGIN_TABLEATTRIBUTESpreference, or on the line before the table using %TABLE{...}%:

Attributes for tables

Argument

Comment

Default value

Example

tableborder

Table border width (pixels).

"1"

tableborder="2"

tablebordercolor

Table border color . Is only visible when cellspacing is larger than 1, or cellborder is 0, or tablerules is none, otherwise the cell borders overlap the table border.

unspecified

tablebordercolor="#333"

tableframe

Table frame, set to "void" (no sides), "above" (the top side only), "below" (the bottom side only), "hsides" (the top and bottom sides only), "lhs" (the left-hand side only), "rhs" (the right-hand side only), "vsides" (the right and left sides only), "box" (all four sides), "border" (all four sides).

unspecified

tableframe="hsides"

tablerules

Table rules, set to "none" (no rules), "groups" (rules will appear between row groups and column groups only), "rows" (rules will appear between rows only), "cols" (rules will appear between columns only), "all" (rules will appear between all rows and columns). See also: headerrules and datarules.

unspecified

tablerules="rows"

tablewidth

Table width: percentage of window width, or absolute pixel value.

unspecified

tablewidth="100%"

headerrows

Number of header rows to exclude from sort. (will be rendered in a HTML thead section)

"1"

headerrows="1"

footerrows

Number of footer rows to exclude from sort. (will be rendered in a HTML tfoot section)

"0"

footerrows="1"

id

Unique table identifier string, used for targeting a table with CSS.

tableN (where N is the table order number on the page)

id="userTable"

summary

Table summary used by screen readers: A summary of what the table presents. It should provide an orientation for someone who listens to the table.

unspecified

summary="List of subscribed users"

caption

Table caption: A title that will be displayed just above the table.

unspecified

caption="Users"

inlinemarkup

Set to "on" to generate inline markup HTML (in addition to the CSS markup); useful if you need to copy the table, for instance to paste the table into an email).

Attributes for data cells

Argument

Comment

Default value

Example

datarules

Set to "none" (no rules), "rows" (rules will appear between rows only), "cols" (rules will appear between columns only), "all" (rules will appear between all rows and columns). Overrides tablerules for data cells.

unspecified

datarules="none"

datavalign

Vertical alignment of data cells; overrides valign.

unspecified

datavalign="top"

dataalign

Data cell alignment, one value for all columns, or a comma separated list for different alignment of individual columns. Set to "left", "center", "right" or "justify". Overrides individual cell settings.

unspecified

dataalign="center"

databg

Data cell background colour, a comma separated list. Specify "none" for no colour, that is to use the colour/background of the page the table is on.

"#edf4f9,#fff"

databg="#f2f2f2,#fff"

databgsorted

Data cell background colour of a sorted column; see databg.

the values of databg

databgsorted="#d4e8e4, #e5f5ea"

datacolor

Data cell text colour, a comma separated list.

unspecified

datacolor="#00c, #000"

Attributes for headers

Argument

Comment

Default value

Example

headerrules

Set to "none" (no rules), "rows" (rules will appear between rows only), "cols" (rules will appear between columns only), "all" (rules will appear between all rows and columns). Overrides tablerules for header cells.

unspecified

headerrules="none"

headerbg

Header cell background colour. Specify "none" for no colour, that is to use the colour/background of the page the table is on.

"#6b7f93"

headerbg="#999"

headerbgsorted

Header cell background colour of a sorted column. Specify "none" for no colour, that is to use the colour/background of the page the table is on.

the value of headerbg

headerbgsorted="#32596c"

headercolor

Header cell text colour.

"#fff"

headercolor="#00c"

headervalign

Vertical alignment of header cells; overrides valign.

unspecified

headervalign="top"

headeralign

Header cell alignment, one value for all columns, or a comma separated list for different alignment of individual columns. Set to "left", "center", "right" or "justify". Overrides individual cell settings.

unspecified

headeralign="left,right"

headerrows

See: Attributes for tables

Other attributes

Argument

Comment

Default value

Example

include

Other topic defining the TABLE parameters. The first %TABLE% in the topic is used. This is useful if you have many topics with the same table format and you want to update the format in one place. Use topic or web.topic notation.

* Set TABLEPLUGIN_TABLEATTRIBUTES = cellpadding="0" <<< this will remove previously set preferences and leave only 1 attribute

If you pass %TABLE{...}% parameters, you partially override previously set preferences:

* %TABLE{datacolor="#f00"}% <<< this will only change the data color attribute

Reserved attributes

The setting disableallsort is normally not used as a TABLE or TABLEPLUGIN_TABLEATTRIBUTES setting. Plugins such as EditTablePlugin dynamically sets disableallsort to disable sorting while editing a table. For this to work it is important that EditTablePlugin runs before TablePlugin, which is the default. The setting sort can be overwritten by a URL parameter or hidden formfield of the same name. Plugins such as EditTablePlugin can use this to disable table header sorting while in edit mode.

ISO dates may have a timezone specifier, either Z or a signed difference in hh:mm format. For example:

2001-12-31T23:59:59+01:00

2001-12-31T23:59Z

Number is digits, with optional decimal point

Otherwise treated as text

If you specify headerrows, then the row with the sort links is the row
closest to the data (the last row in the header). If you do not specify
headerrows, the first row that has a heading in the first column is the
sort row. To sort by the first footer row, set headerrows="0".

Sorting example

Row spans

Table cells with a single caret indicate follow-up rows of multi-row spans. For example,

| One One | One Two | One Three |
| ^ | Two Two | Two Three |
| Three One | ^ | Three Three |

Results in:

One One

One Two

One Three

Two Two

Two Three

Three One

Three Three

Note: Row spans do not work across the header and body boundaries of a table. So it you have a header row, the row cells beneath (in the body section) cannot be merged with the header row cells. Row spans within header cells are possible.

TablePlugin Global Settings

Make all tables in a topic sortable. If this is set to all, all tables that have a header row (including those that do not have %TABLE before them) will be made sortable. If set to none, only tables with %TABLE will be sortable. Topic rendering is faster if this is set to none.

all

TABLEPLUGIN_TABLEATTRIBUTES

Default table attributes. These are first defined in Configure, and can be set on site level in Main.SitePreferences, on web level in WebPreferences or on topic level.

1.043: Kenneth Lavrsen: Added check for valid value for initsort. Ignore if it is not a number.

12 Sep 2009

1.042: Kenneth Lavrsen: Added a new API call initialiseWhenRender which plugins like CompareRevisionsAddOn can use to reset the table counters between two renderings of the same topic

03 Sep 2009

1.041: Kenneth Lavrsen: Fix for crash when cell contains the number 0. Allow sorting of negative numbers even when suffixed with unit. Treat whitespace as zero if pure numerical context.

02 Sep 2009

1.040: Kenneth Lavrsen: Fixed the fix of parsing date-time columns so that plain numbers are not interpreted as dates causing wrong sorting

03 Jun 2009

1.039: Michael Daum: fixed parsing date-time columns

19 Apr 2009

1.038: Removed support for settings in the plugin topic which is a bad idea anyway as they get overwritten at each Foswiki upgrade. Define the global settings in Main.SitePreferences instead. Fixed an issue where TablePlugin produced invalid css if no 'px' or '%' is passed in a size parameter. Small refactoring in style attribute handling.

16 Dec 2008

1.037: Foswiki version

30 Sep 2008

1.035: Fix sorting of attachment date column.

03 Aug 2008

1.034: TWiki 4.2.1 release version

20 Mar 2008

1.033: TWikibug:Item5387: allow rowspanned columns to contain HTML tags; otherwise it is impossible to add an invisible anchor to a rowspanned cell

16 Dec 2007

1.030: Kenneth Lavrsen: Fixed the problem of tables being sorted by by TablePlugin while the table is being edited by plugins such as EditTablePlugin. This required adding a new attribute disableallsort so plugins such as EditTablePlugin can temporarily disable all sorting for a table. Additionally the CGI variable (URL parameter or hidden formfield) sort can be set to "off" which disables all header sorting in the topic. This is used by plugins such as EditTablePlugin to disable the sorting by clicking header fields during editing of tables. Ref: TWikibug:Item5135 and TWikibug:Item2690.

1.020: Kenneth Lavrsen: Fixed initsort so all tables can be initsorted and not only the first. When you sort a table by clicking on the header of a column the table gets sorted accordingly. When you click the header of another table the previously sorted table goes back being sorted as specified by initsort.

13 Dec 2006

1.019: Arthur Clemens: Prevent sorting of columns that do no exist.

02 Dec 2006

1.018: Arthur Clemens: Data rows now start with first datacolor and databgcolor.