preDraw
Pre-draw event - triggered as the table is about to be redrawn.
Description
This event is triggered when DataTables starts its draw action (finally resulting in the draw event) and can be used to inform you of this state.
This event can also be used to cancel the draw by returning false from the event handler. Please note that if you do this it can leave the table in an unpredictable state as any settings are not reset to their values from before the draw action - for example using order() to change the ordering of the table, but if the draw action is cancelled the data will still have been ordered internally in DataTables, but just not displayed.
Please note that, as with all DataTables emitted events, the event object has a DataTables API instance available on it in the dt property.
Type
function( e, settings )
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | e | No | |
Event object | |||
| 2 | settings | No | |
DataTables settings object | |||
Example
Log time taken to draw the page:
var table = new DataTable('#myTable');
var startTime;
table
.on('preDraw', function () {
startTime = new Date().getTime();
})
.on('draw', function () {
console.log('Redraw took at: ' + (new Date().getTime() - startTime) + 'mS');
});Related
The following options are directly related and may also be useful in your application development.