Skip to content
Dave Newton edited this page May 21, 2020 · 10 revisions

Introduction

A tag that renders a DataTables-powered html table. This tag is based on the DataTables plugin.

For custom locals use the head tag.

NOTE: This plugin comes with json translation files embedded within the jar. Although they come from DataTables official site, some of these translations are incomplete. More info there.

Basically, this tag binds its attributes to DataTables initialization parameters. So it's highly recommended to have a look to DataTables official manual, examples and reference in order to understand how this library works.

This plugins also binds DataTables native JavaScript events to Struts 2 jQuery Plugin's topic system.

It also provide some useful Java classes, that will help you to implement server side processing (searching, paging, sorting,..) in a Struts 2 Action.

Besides this documentation, you'll find some useful examples in the Struts 2 jQuery Showcase App, section widgets > DataTables.

This plugin is quite recent, so it is subject to enhancements, API changes, ... Feel free to open a ticket to give your opinion on what could be improved/fixed.

Features

  • Supports client and server side processing
  • Supports AJAX and DOM datasources.
  • Supports HTML5 attribute configuration
  • Supports internationalization
  • Supports DataTables themes. Default theme, jquery ui and bootstrap are embedded within this plugin.
  • Native JS events binded to topics.
  • Supports DataTables JS callbacks.
  • Officials open source plugins are embedded : select, buttons,responsive,...

Attributes

Configuration attributes

Name

Required

Default

Evaluated

Type

Description

ajax false true String Configuration of an AJAX Datasource for the Table. Expect a string (url), oan object(jQuery ajax like config object), or a custom function. See datatables reference for more infos
autoFill false false true String AutoFill plugin configuration. True to enable with defaults, JS object to enable with custom options.
autoWidth false true true Boolean Enable/disable automatic column width calculation.
buttons false false true String Buttons plugin configuration. True to enable with defaults, JS object to enable with custom options.
colReorder false false true String ColReorder plugin configuration. True to enable with defaults, JS object to enable with custom options.
columns false true String Configuration of columns. Expect a JS array, as specified by datatables manual.
columnDefs false true String Other way of configuring columns. Expect a JS array, as specified by datatables manual.
createdRow false true String Callback for whenever as TR element is created for the table's body.
data false true String Use of a JS array as dataSource for the table
datatablesTheme false "default" true String the theme for DataTables.
deferLoading false true String When server side processing is enabled, and initial data is already in the DOM content of the table, if this option is setted with the full dataset size, datatables will defer requesting the server until needed.
deferRender false false true Boolean Defers initial rendering for additional speed up of initialisation
displayStart false 0 true Number Initial page to show.
dom false true String DataTables dom configuration. See DataTables offical reference.
fixedColumns false false true String Fixed plugin configuration. True to enable with defaults, JS object to enable with custom options.
fixedHeader false false true String FixedHeader plugin configuration. True to enable with defaults, JS object to enable with custom options.
info false true true Boolean enable/disable information display
keys false false true String KeyTable plugin configuration. True to enable with defaults, JS object to enable with custom options.
lengthChange false true true Boolean enable/disable paging length select
lengthMenu false [10,25,50,100] true String Specify the entries in the drop down select for pagination.Expect a 1D array containing integer values of page length or a 2D array with first index being the page lengths and second index being the dispalyed options.
ordering false true true Boolean enable/disable ordering
order false [ [0,'asc'] ] true String initial order to apply to the table. Must be an array of arrays, the inner arrays comprised of : column index to order upon, and 'asc' or 'desc' string.
orderCellsTop false false true Boolean Control whether DataTables should use the top (true) unique cell for a single column, or the bottom to attach the default order listener.
orderClasses false true true Boolean Highlight the column being ordered in the table body.
orderFixed false true String ordering to be always applied to the table. See 'order' attribute for argument detail.
orderMulti false true true Boolean Enable/Disable multiple column ordering.
paging false true true Boolean enable/disable paging
pageLength false 10 true Number change the initial page length.
pagingType false "simple_numbers" true String Pagination buttons display options.Expects a string whin can be 'numbers': page buttons number only, 'simple': previous and next buttons only, 'simple_numbers' : previous, next plus page numbers, 'full' : first previous next and last buttons, 'full_numbers' : full + numbers.
processing false false true Boolean enable/disable processing message
renderer false true String Display component renderer type.See DataTables reference for more infos.
responsive false false true String Responsive plugin configuration. True to enable with defaults, JS object to enable with custom options.
rowId false true String Data property name that must be used to set tr elements DOM IDs.
rowReorder false false true String RowReorder plugin configuration. True to enable with defaults, JS object to enable with custom options.
scrollCollapse false false true Boolean Allow the table to reduce in height when a limited number of row is shown.
scrollX false false true String controls horizontal scrolling, can be true (auto), or any CSS unit, or any Number
scrollY false false true String controls vertical scrolling, can be true (auto), or any CSS unit, or any Number
searching false true true Boolean enable/disable searching
search false true String Search feature configuration. See DataTables reference for more infos.
searchCols false true String Define an initial search for individual columns.Expect an array of the same size as the number of columns, containing an object with 'search' and 'escapeRegex' properties.
searchDelay false null true Integer Set a throttle frequency for searching.expect an integer.
serverSide false false true Boolean Enable/disable server side processing of searching, paginating,ordering,...
stateSave false false true Boolean Enable/disable state saving feature.
stateDuration false 7200 true Integer Saved state validity duration, in seconds.
stripeClasses false ['odd','even'] true String Sets the zebra stripe class names for the rows in the table.Expect an array of class names.
scroller false false true String Scroller plugin configuration. True to enable with defaults, JS object to enable with custom options.
select false false true String Select plugin configuration. True to enable with defaults, JS object to enable with custom options.

JavaScript Callbacks

Name

Required

Default

Evaluated

Type

Description

drawCallback false true String Callback called every time DataTables performs a draw.
footerCallback false true String Footer dispplay Callback.
formatNumber false true String Number formatting Callback.
headerCallback false true String Header display Callback.
infoCallback false true String Table summary display Callback.
initComplete false true String Initialisation complete Callback.
preDrawCallback false true String Pre draw Callback.
rowCallback false true String row draw Callback.
stateLoadCallback false true String Callback that define where and how a saved state should be loaded.
stateLoaded false true String State loaded Callback.
stateLoadParams false true String State loaded - data manipulation Callback.
stateSaveCallback false true String Callback that define how the table state is stored and where.
stateSaveParams false true String State save - Data manipulation Callback.

Topics

Name

Required

Default

Evaluated

Type

Description

ajaxReloadTopics false true String Comma separated list of topics that trigger an AJAX reload.
clearTableTopics false true String Comma separated list of topics that trigger a table clear.
orderTopics false true String Comma separated list of topics that trigger a table order. The data attribute contains ordering params.
pageTopics false true String Comma separated list of topics that trigger a table page change. The data attribute contains the page number.
pageLengthTopics false true String Comma separated list of topics that trigger a page length change. The data attribute contains page length.
redrawTopics false true String Comma separated list of topics that trigger a table redraw.
searchTopic false true String Comma separated list of topics that trigger a search. The data attribute contains searching param.
stateClearTopics false true String Comma separated list of topics that trigger a state clear.
stateSaveTopics false true String Comma separated list of topics that trigger a state save.
onAutoFillTopics false true String Comma separated list of topics fired when an autoFill action has been completed.
onBeforeAutoFillTopics false true String Comma separated list of topics fired when an auto fill action is about to be applied to the table.
onButtonActionTopics false true String Comma separated list of topics fired when a button action has been triggered.
onColumnReorderTopics false true String Comma separated list of topics fired when columns have been reordered by user or API.
onColumnSizingTopics false true String Comma separated list of topics fired when column are resized.
onColumnVisibilityTopics false true String Comma separated list of topics fired when column visibility change.
onDestroyTopics false true String Comma separated list of topics fired the datatable is destroyed.
onDrawTopics false true String Comma separated list of topics fired when a draw has finished.
onInitCompleteTopics false true String Comma separated list of topics fired datatable initialization is complete.
onInitStartTopics false true String Comma separated list of topics fired when initialisation started, immediately before data load.
onKeyBlurTopics false true String Comma separated list of topics fired when KeyTable has blurred focus from a cell.
onKeyFocusTopics false true String Comma separated list of topics fired when KeyTable has focused a cell.
onOtherKeyTopics false true String Comma separated list of topics fired when a key event has been detected and is not handled by KeyTable.
onOrderTopics false true String Comma separated list of topics fired when data contained in the table is ordered.
onPageChangeTopics false true String Comma separated list of topics fired when paging is updated.
onPageLengthChangeTopics false true String Comma separated list of topics fired when the page length has changed.
onProcessingTopics false true String Comma separated list of topics fired when data is processed.
onProcessingErrorTopics false true String Comma separated list of topics fired when an error occured while processing data.
onSearchTopics false true String Comma separated list of topics fired when the table is filtered.
onStateLoadedTopics false true String Comma separated list of topics fired when state has been loaded and applied.
onStateLoadingTopics false true String Comma separated list of topics fired when state is beeing loaded from storage.
onStateSavingTopics false true String Comma separated list of topics fired when column state is beeing stored.
onResponsiveDisplayTopics false true String Comma separated list of topics fired when the details for a row has been displayed, updated or hidden.
onResponsiveResizeTopics false true String Comma separated list of topics fired when the columns displayed by Responsive has changed due to resize.
onRowReorderTopics false true String Comma separated list of topics fired when row have been reordered by the user, when dropping is done, but before data change is applied.
onRowReorderedTopics false true String Comma separated list of topics fired when rows have been reordered by the user.
onDeselectTopics false true String Comma separated list of topics fired when items have been deselected.
onSelectTopics false true String Comma separated list of topics fired when items have been selected.
onSelectItemsTopics false true String Comma separated list of topics fired when select items type change event.
onSelectStyleTopics false true String Comma separated list of topics fired when select items style change event.
onUserSelectTopics false true String Comma separated list of topics fired when a user action cause items to be selected in the table.