Wiki

Clone wiki

grails-datatables / errorFunction

errorFunction

Values

Name Type Default
errorFunction String None

Description

errorFunction is a table option that allows you to specify a JavaScript function that will be called when an error occurs in the DataTable. One example of an error that can occur is when you are using server-side processing and the user allows his session to expire in between page changes. When this happens, the controller will respond with an error message instead of the table data the user requested.

You can read more about DataTables error handling on the error event description page.

Example

<dt:datatable name="MyTable" serverSide="true" errorFunction="dataTableError">
    <dt:column name="myFirstColumn"/>
    <dt:column name="mySecondColumn"/>
</dt:datatable>

The above example sets the errorFunction to dataTableError. The effect of this is that $.fn.dataTable.ext.errMode will be set to none (which eliminates the default error message popup), and the dataTableError function (which you must provide) will be called with the parameters defined on the error event description page. This allows you to handle the error as you wish.

Note that if you wish to provide a single errorFunction for multiple tables, it is simpler to include this option in the configuration using the grails.plugin.datatables.tableDefaults map, rather than in each table. Refer to the example on the Options page for more information on that.

See Also

serverSide


Back to Options.

Updated