Help:Table format

The result format table is used to format query results as tables. It is Semantic MediaWiki's default way of formatting query results for all queries that have one or more additional printout statements. It is almost identical to.

Sorting
Tables have a special feature for sorting their contents by any of the columns in the table. See Help:Selecting pages for general comments on sorting and a comparison to the wiki's query result sorting. Browsers without JavaScript enabled will not see the buttons for sorting at all.

Examples
The following examples demonstrate the output of simple queries using different classes for generating the respective overall appearance of the table.

This is the default class for queries with printout statements and does not need to be specified explicitly. Same for specifying the format to be used, i.e.  which is the default for queries with printout statements.


 * Syntax


 * Result

Available since .CiteRef::gh:smw:4048 The format to be used does not need to be specified explicitly since it is the default for queries with printout statements. It can be combined with class  provided by MediaWiki core as a utility allowing users to control the sorting of the columns contents.


 * Syntax


 * Result

Available since .CiteRef::gh:smw:2420 The format to be used does not need to be specified explicitly since it is the default for queries with printout statements. See below for more related classes.


 * Syntax


 * Result

Applying CSS formatting
As of the native MediaWiki sortable tables are used. Thus this format now provides several ways for custom formatting to be applied to tables:
 * One or more overall CSS classes can be set for the table, using the "class=" parameter.
 * Each column in the table gets a class name that derives from the column name. For instance, if a column is titled "Capital city", the column's class will be "Capital-city".
 * Rows in the table each get either the class "row-odd" or "row-even", depending on whether the row is odd or even.

In this way, specific formatting, like colors and font sizes, can be set across a single table, or for a specific column, or can be set for alternating rows. The recommended way to set any custom CSS in the wiki is by modifying the page "MediaWiki:Common.css".

The example below will result in the display of alternating rows.
 * Example for alternating row colours

introduces type related attribution allowing to apply specific formatting rules based on the datatype uses (data value types like " ", " " etc.) used in a column.CiteRef::gerrit:smw:53520
 * Data value type attributes

The class attribute is a concatenated string that includes " " + " " resulting in " " for the data value of datatype "Date". If you want all numeric representations (prerequisite is that the property selected for display is of datatype "Number") in a table to be formatted on the right side, you would need to add:

Predefined datatable classes
In contrast to, introduced a set of predefined classes supporting a datatable outputCiteRef::gh:smw:2420 in the table format which allows to search the table and to display more results without bloating the display of the table on the wiki page.CiteRef::gh:smw:2420:294453317CiteRef::sb:smw:2420:1

Possible options for parameter "class" are: These classes makes use of the "DataTables" table plug-in for jQueryCiteRef::url:DataTables-DataTables. Using these classes produces a basic output as offered by provided by  which also makes use of the "DataTables" table plug-in for jQuery. The latter is however more powerful in its usage. CiteRef::gh:smw:2420:294453317
 * or the combination of the previous two
 * .CiteRef::sb:smw:2420:2.
 * or the combination of the previous two
 * .CiteRef::sb:smw:2420:2.

The features of this class are
 * nicer visual appearance
 * search input box for searching within the table
 * easy export of the table's content into CSV, JSON, RSS and RDF

Custom skins
If you are using custom skins other class attributes may be available. E. g. if you use a skin that implements boostrap, you can use class attributes such as