Extension:DataTables

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
DataTables

Release status:Extension status beta

ImplementationTemplate:Extension#type Media, Hook
DescriptionTemplate:Extension#description Adds the jQuery Extension DataTables to MediaWiki
Author(s)Template:Extension#username Daniel Renfro, Allan Jardine (DanielRenfrotalk)
Latest versionTemplate:Extension#version 1.2 (2014-05-20)
MediaWikiTemplate:Extension#mediawiki 1.17.0+
PHPTemplate:Extension#php 5.2.3+
LicenseTemplate:Extension#license GPL
Download https://github.com/bluecurio/mediawiki-extension-datatables
Hooks usedTemplate:Extension#hook
ResourceLoaderRegisterModulesManual:Hooks/ResourceLoaderRegisterModules

Translate the DataTables extension if it is available at translatewiki.net

Check usage and version matrix.

What can this extension do?[edit]

Adds the DataTables extension for jQuery to MediaWiki using the ResourceLoader. This extension is a thin wrapper around the jQuery library written by Allan Jardine; it is meant to provide the DataTables library for developers and is not intended to be a feature for wiki-users to use.

Usage[edit]

To use this library in your custom MediaWiki extension, define ext.datatables as a dependency when registering your ResourceLoader module. That's it! MediaWiki will take care of the rest. You can go ahead and use the library right away. Like so:

$myResourceLoaderModule => array(
	'scripts'      => 'js/ext.myExtension.js',
	'styles'       => 'css/ext.myExtension.css',
	'dependencies' => array(
		'ext.datatables',
                // other javascript libraries...
	)
);

You can then have your JavaScript call datatables using the typical call:

$( '#example' ).dataTable();

Please see the excellent documentation of DataTables at http://datatables.net/. There are many examples and this code is quite flexible.

Download instructions[edit]

You can install this extension by cloning the Github repository or by downloading a ZIP file from Github and installing it manually. (See below.) Once you have the code in place, add the following to LocalSettings.php:

# DataTables
require_once( "$IP/extensions/DataTables/DataTables.php" );

Installing with git[edit]

From the command-line, clone the github repository into your extensions/ directory, like so:

$ git clone https://github.com/bluecurio/mediawiki-extension-datatables extensions/DataTables

Installing as a ZIP[edit]

If you don't have git installed on your computer, please follow the following directions:

  1. Browse to https://github.com/bluecurio/mediawiki-extension-datatables
  2. Find the button that says "Download ZIP" and click it
  3. Download the ZIP file and put it on your computer in your Mediawiki's extensions/ directory
  4. Unzip it
  5. Rename the folder to DataTables


Configuration parameters[edit]

None!

More documentation[edit]

The http://datatables.net/ website is a wonderful resource for learning to use the jQuery library. I highly recommend having a look at the examples and reading through the configuration settings.


See also[edit]