drawCallback
Function that is called every time DataTables performs a draw.
Description
It can be useful to take an action on every draw event of the table - for example you might want to update an external control with the newly displayed data, or with server-side processing is enabled you might want to assign events to the newly created elements. This callback is designed for exactly that purpose and will execute on every draw.
Type
Examples
Notify whenever DataTables does a draw:
new DataTable('#myTable', {
drawCallback: function (settings) {
alert('DataTables has redrawn the table');
}
});
Use API method in the callback to get the data for the rows in the draw:
new DataTable('#myTable', {
drawCallback: function (settings) {
var api = this.api();
// Output the data for the visible rows to the browser's console
console.log(api.rows({ page: 'current' }).data());
}
});
Related
The following options are directly related and may also be useful in your application development.