The WebJET DataTables framework wraps datatables.net with a Spring REST back-end and a custom editor extension. A singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/webjetcms/webjetcms/llms.txt
Use this file to discover all available pages before exploring further.
WJ.DataTable(options) call produces a fully functional table with inline editing, search, paging, sorting, export/import, and permission-aware buttons.
Column definitions are generated from Java entity annotations (see Column definitions) and passed into the constructor. The REST endpoint is implemented by extending DatatableRestControllerV2 (see REST controller).
Basic example
WJ.DataTable(options) constructor
Required options
Base URL of the REST service. The datatable appends
/all to retrieve all records (unless noAll is set), findByColumns for searching, and /editor for saving.Column definitions. Generate these from Java annotations using
layout.getDataTableColumns('com.example.MyEntity') in Thymeleaf/Pug templates.Display and paging
When
true, paging, ordering, and searching are delegated to the server via REST calls. When false, all data is loaded upfront and processed client-side.Set to
false to disable pagination and render all returned rows.Default sort order. Because Thymeleaf evaluates
[[...]] expressions, build the array through a variable:Set to
false to stop the browser from remembering column order and layout between sessions.By default the table stretches to fill the available window height. Set to
false to use natural content height instead.Identifiers
Unique identifier for the datatable. Required when multiple datatables exist on one page.
Unique identifier for the editor instance. Defaults to
id.Editor tabs
Tab definitions for the editor dialog. Each entry has at minimum
id and title. Optional attributes:selected— marks the default tab.className— addhide-on-create,hide-on-edit, orhide-on-duplicate.perms— hide the tab if the user lacks the named permission.hideOnCreate/hideOnEdit— boolean shortcuts.content— raw HTML to inject; the tab will have no editor fields.
AJAX event hooks
Called after data loads. Signature:
function(TABLE, e, settings, json, xhr).Called before each request. Use it to append extra parameters (prefix with
fixed_ to distinguish from datatable parameters):Called when a row’s edit link is clicked. Signature:
function(TABLE, row, dataAfterFetch, dataBeforeFetch). Open the standard editor with TABLE.wjEdit(row).Called for each rendered row. Use it to apply CSS classes dynamically:
Pre-fetch behaviour
When
true, a REST call refreshes the current record’s data from the server before the editor opens, ensuring you always edit the latest version.When
true, a REST call with ID -1 fetches default values for a new record before the create editor opens.Button and permission control
Comma-separated list of button names to hide, e.g.
"create,import,export".Map each operation to a permission name. Hides the toolbar button and the corresponding editor action button when the user lacks the right:Check permissions at runtime with
TABLE.hasPermission('create').Custom buttons that replace the default Save button in the editor:
Data initialisation
Pre-loaded data used on the first render, avoiding an extra REST call. Set
initialData.forceData = true to use empty initial data unconditionally.Pre-applied filter values keyed by CSS selector. Applied before the first REST call:
Footer sum
Displays a footer row that sums selected numeric columns:
mode: "all"— sums across all pages (calls/sumAllwhenserverSide: true).mode: "visible"— sums only the current page.mode: "datatable"— usesDatatablePageImpl.summaryreturned by the REST service.
Other options
Prevents appending
/all to the URL. Search will not work when set.Comma-separated column names to suppress from the display, e.g.
"whenToPublish,datePublished".Set to
false to disable Ctrl+S/Cmd+S saving in the editor.Set to
false to turn off the concurrent-edit notification service.Set to
true for a datatable embedded as a field inside another editor. Adds the DTE_nested_modal CSS class.Column renderFormat values
The renderFormat property controls how cell values are presented and which header options appear.
| Value | Description |
|---|---|
dt-format-selector | Checkbox to select the row; use as the first column |
dt-format-none | No header options |
dt-format-text | Plain text with HTML escaping |
dt-format-text-wrap | Same as text but wraps; auto-set for TEXTAREA fields |
dt-format-select | Renders from editor.options |
dt-format-checkbox | HTML checkbox |
dt-format-boolean-true / dt-format-boolean-yes / dt-format-boolean-one | Boolean display |
dt-format-number / dt-format-percentage | Numeric display |
dt-format-number--decimal / dt-format-percentage--decimal | Decimal numeric |
dt-format-number--text | Rounded number; large values shown as e.g. 10k |
dt-format-filesize | File size as 10.24 kB |
dt-format-date / dt-format-date-time | Date/time with from–to filter |
dt-format-date--text / dt-format-date-time--text | Date as text |
dt-format-link | Text as hyperlink; use with renderFormatLinkTemplate |
dt-format-image | Thumbnail preview with link and text |
dt-format-image-notext | Thumbnail preview only |
dt-format-mail | Text as mailto: link |
dt-row-edit | Inline row-edit trigger |
renderFormatLinkTemplate to a URL pattern (e.g. "/temps-list.html" or "javascript:;") and renderFormatPrefix for a leading icon:
Displaying raw HTML
By default, DataTables escapes HTML to prevent XSS. To allow HTML rendering in a cell, add theallow-html CSS class:
Row styling
Rows can receive CSS classes to indicate status. UseBaseEditorFields.addRowClass(String) in your EditorFields implementation:
onRowCallback:
| Class | Appearance |
|---|---|
is-disabled | Red — inactive item |
is-disapproved | Red — unapproved item |
is-not-public | Red — non-public item |
is-default-page | Bold — main page of a directory |
data.editorFields.rowClass on each row and applies it automatically via the rowCallback option.
Status icons
Status icons display record state inline in a dedicated column backed byEditorFields. Use BaseEditorFields.addStatusIcon(String className) to add icon CSS classes, then define the column using @DataTableColumn with the name statusIcons:
value in each option follows the pattern property:condition and drives server-side filtering. Supported conditions:
| Pattern | Meaning |
|---|---|
property:true | Attribute is true |
property:false | Attribute is false |
property:notEmpty | Attribute is not empty |
property:empty | Attribute is null or empty string |
property:%text% | Attribute contains text (LIKE search) |
property:!%text% | Attribute does not contain text (NOT LIKE) |
JavaScript API
Execute a server-side action
/action/{action} on the server. The following events fire afterward:
WJ.DT.executeAction— on successful completion.WJ.DT.executeActionCancel— on failure or when the user cancels.
Adding toolbar buttons
init visibility helpers:
| Helper | Behaviour |
|---|---|
showIfRowSelected(this, dt) | Active when ≥ 1 row selected |
showIfRowUnselected(this, dt) | Active when no rows selected |
showIfOneRowSelected(this, dt) | Active when exactly 1 row selected |
Events
| Event | When fired |
|---|---|
WJ.DTE.open | Editor window is opening |
WJ.DTE.opened | Editor window is fully visible |
WJ.DTE.close | Editor window is closing |
WJ.DTE.forceReload | REST service requested a datatable refresh |
WJ.DTE.tabclick | Tab clicked in the editor |
WJ.DTE.submitclick | Save button clicked |
WJ.DTE.closeclick | Close button clicked |
WJ.DTE.xhrfetch | Data loaded via fetchOnEdit |
WJ.DTE.resize | Editor window maximised/minimised |
