Help:Datatables format

Datatables format
A progressive table result printer that integrates the DataTables JavaScript library
Further Information
Provided by: Extension "Semantic Result Formats"
Added: 1.9.0
Removed: still supported
Requirements: none
Format name: datatables
Enabled? Indicates whether the result format is enabled by default upon installation of the respective extension. yes
Authors: James Hong Kong
Categories: table
Group: smwapi
Table of Contents

Starting with Semantic Result Formats 1.9.0, the powerful DataTables JavaScript library has been integrated to be available as a result printer. This result printer enables advanced interaction such as in-table search, on-the-fly filtering or variable length pagination.

Semantic MediaWiki 3.0.0Released on 11 October 2018 and compatible with MW 1.27.0 - 1.31.x. introduced a set of predefined classes supporting a datatable output1 in the result format "Table"Outputs the results in a table (default for queries with printout statements).. Note that using the table result format with the "datatable" class is different than using the datatables result format!


This result printer is a full-fledged JavaScript result printer which works solely on the basis of interacting with the Semantic MediaWiki through its SMWApi which makes this result printer less dependent on changes within Semantic MediaWiki but also promotes data being dynamically refreshed and adopted while the page is being displayed.

  • In-table search
  • Result pagination
  • Instant update
  • Query panel

Query panel[edit]

Along with the "DataTables" plug-in, the query panel (see explanations or see the video on the left side) is an additional component that allows results to be adapted according to an user needs. Meaning that while the in-page inline queries using the #ask parser function query will carry the responsibility of generating the base table content, content alteration can be achieved by adapting:

  • Parameters such as the limit parameter can be changed on-the-fly
  • Table content can be refreshed in a blink of an eye without the need to alter the #ask query
  • Conditions can be altered (this is only temporary until the next page refresh where the original conditions are restored)
  • If the user enables the auto-refresh functionality via his/hers user preferences, table content is automatically being refreshed during a page refresh/reload
  • If the user enables local storage support, result objects are stored for 15 min locally while image/thumbnail url information are stored for 24h. Disabling local storage will force the result printer always to request a server response instead of using available cache information.


 [[Modification date::+]]
 |?Modification date



Parameter Type Default Description
source text empty Alternative query source
limit whole number 50 The maximum number of results to return
offset whole number 0 The offset of the first result
link text all Show values as links
sort list of texts empty Property to sort the query by
order list of texts empty Order of the query sort
headers text show Display the headers/property names
mainlabel text no The label to give to the main page name
intro text empty The text to display before the query results, if there are any
outro text empty The text to display after the query results, if there are any
searchlabel text ... further results Text for continuing the search
default text empty The text to display if there are no query results
NoteNote: The following parameters do not apply to this result format: headers, link, order, searchlabel and sort despite them being listed here.

Format specific[edit]

Parameter Type Default Description
class text empty Specify an additional cascading style sheet class
theme text bootstrap Select a grid theme


User preferences[edit]

Available user preferences are described here.

Maximum number of results[edit]

Because the results are printed through a single inline query on a single page, the maximum number of rows printed is set by configuration parameter $smwgQMaxInlineLimitSets the maximal number of rows ever printed by queries (500 by default) rather than configuration parameter $smwgQMaxLimitSets the maximal number of results ever retrieved by queries. The limit parameter will not normally help to increase the number beyond this limit, although this may work after the user has hit the refresh button in the top right.


In-table images[edit]

Thumbnails (or in-table images) are queried after the table has been generated in order to keep the browser and the page responsive. Information about an image/thumbnail are requested via ajax after the table has been displayed which depending on the server response time can take a moment before all image links are replaced with its corresponding thumbnail. In case you use the local storage options, images information available to the cache should be available in an instant.

Issues with Safari on MW 1.27.x[edit]

In case the results are not loading properly you have to upgrade MediaWiki to version 1.27.2 or later or add the following configuration setting to your "LocalSettings.php" file:2$wgLegacyJavaScriptGlobals = false;


  • Currently (as of SMW 2.5.x and SMW 2.4.x) default sorting of columns is not supported.3
  • Common wiki markup, such as that for italic or bold, is often not rendered by the datatables format. Some of the necessary tags, however, can be replaced using HTML text formatting in their stead (for instance, replace ''italic'' with <i>italic</i>).
  • This result format cannot represent values from


See also[edit]

This documentation page applies to all SMW versions from 1.9.0 to the most current version.


  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:2420
  2. ^  Semantic Result Formats: GitHub issue comment gh:srf:176:254289047
  3. ^  Semantic MediaWiki: Default sorting in datatables result format