Wiki
Clone wikigrails-datatables / functionsTemplate
functionsTemplate
Values
Name | Type | Default |
---|---|---|
functionsTemplate | String | None |
Description
functionsTemplate
is a configuration option that allows you to specify the name of a template containing JavaScript functions that you would like to include with your tables. This is useful if you are using your own functions to download reports or to handle a DataTable error.
The template is optional, but if used it must be specified including its path. If the template exists in a plugin, you must also specify the name of that plugin using the functionsTemplatePlugin configuration option. The template must contain only JavaScript. It need not contain the <script>
tag as that will be provided by the plugin.
Only one copy of the template will be included in each page containing a DataTable.
The template will be passed the following parameters:
dataTablesConfig
- The map of configuration file options.tableDefinition
- The object containing the table definition (refer to the source code for more information).attr
- The attributes passed to thedt:datatable
tag.
Example Configuration File Entry
grails.plugin.datatables.functionsTemplate = "/dataTables/dataTablesFunctionsTemplate"
Example Template Filename:
/grails-app/views/dataTables/_dataTablesFunctionsTemplate.gsp
Example _dataTablesFunctionsTemplate.gsp
File:
function downloadReport(clickEvent, numRecords, reportUrl) { // Code to download the report, e.g. using the jquery.fileDownload plugin. } function dataTableError(e, settings, techNote, message) { // Custom error handling here. }
See Also
functionsTemplatePlugin, errorFunction, reportFunction
Back to Options.
Updated