{datatable:selector:options}

Description

Turns plain HTML tables into interactive DataTables (the DataTables.net jQuery plugin): client-side paging, sorting, filtering, and search. It matches every table whose CSS selector is selector and calls DataTable(options) on it. The command itself prints nothing - it registers the DataTables library and an init script into the page head and footer, so the page must use generate:HEAD and generate:FOOT in its Site module for the table to activate. The selector defaults to .datatable (any table with class datatable). options is an optional JSON object forwarded verbatim to DataTable(), e.g. paging and info toggles. Note: experimental - the bundled version does not sort Czech or other accented characters correctly by default.

Parameters

selector optional default .datatable

CSS selector for the table(s) to turn into a DataTable. Any selector jQuery understands works - .myclass, #myid, table.report. Every matching table gets paging, sorting and search.

options optional default (none)

Optional JSON object passed verbatim to the DataTables DataTable() call to configure behaviour - for example paging, info, searching, pageLength, or order. Omit it for default DataTables behaviour.

Examples

test[{datatable:}]
Expected[]
Actual[]
With no selector, every table carrying class datatable becomes an interactive DataTable. The command emits nothing into the content - it only registers the library and init script - so wrapped in brackets the output is empty.
test[{datatable:#report-table}]
Expected[]
Actual[]
Pass a CSS selector to activate just one table - here the table with id report-table. Output is still empty; the effect is the loaded DataTables init script.
test[{datatable:.datatable:{ paging:false, info:false }}]
Expected[]
Actual[]
The second argument is a JSON object forwarded verbatim to DataTable(). Here paging and the info line are turned off. The command prints nothing regardless of options.