Help:Datatables format (legacy)

Datatables format (legacy)
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-legacy
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.

In contrast to preceding versions, starting with Semantic Result Formats 4.1.0 one needs to specify datatables-legacy instead of datatables for the "format" option on an inline query. in contrast to preceding versions. Moreover, do not rely on this result format being available in future releases. Thus it is suggested to migrate to the new result format "datatables"Provides a complete porting of DataTables JavaScript library into Semantic MediaWiki.
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 the table result format with the "datatable" class differs from the datatables result format!


This result printer is a full-fledged JavaScript result printer which works solely based on 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 a 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, the 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 their user preferences, table content is automatically 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 is stored for 24h. Disabling local storage will force the result printer to always request a server response instead of using available cache information.


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



A fatal error occurred in the #smwdoc parser function

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 typically 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 to keep the browser and the page responsive. After displaying the table, information about an image/thumbnail is requested via ajax. Depending on the server response time, it can take a moment before all image links are replaced with their corresponding thumbnail. If you use the local storage options, image information available to the cache should be instantly available.

Issues with Safari on MW 1.27.x[edit]

In case the results are not loading correctly, 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]


  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