{hero}

initComplete

Since: DataTables 1.10

Initialisation complete callback.

Description

It can often be useful to know when your table has fully been initialised, data loaded and drawn, particularly when using an ajax data source. In such a case, the table will complete its initial run before the data has been loaded (Ajax is asynchronous after all!) so this callback is provided to let you know when the data is fully loaded.

Additionally the callback is passed in the JSON data received from the server when Ajax loading data, which can be useful for configuring components connected to your table, for example Editor fields.

Type

function initComplete( settings, json )

Parameters:

Examples

Show an alert when the table has fully loaded:

new DataTable('#myTable', {
	initComplete: function (settings, json) {
		alert('DataTables has finished its initialisation.');
	}
});

Show a loading message while the table is being initialised (processing will do this as well):

$('<div class="loading">Loading</div>').appendTo('body');

new DataTable('#myTable', {
	initComplete: function (settings, json) {
		$('div.loading').remove();
	}
});

Related

The following options are directly related and may also be useful in your application development.