order

Since: DataTables 1.10

order event - fired when the data contained in the table is ordered.

Description

The order event is fired whenever the data in the table is ordered. This is typically triggered by the end user ordering a column, but can also be initiated through the order() method and when a full redraw (by calling the draw()) occurs.

Note that the order will be fired before the table has been redrawn with the updated data, although the data will internally have been ordered.

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, ordArr )

Parameters:

Example

Show information about the current order using the API:

var table = new DataTable('#myTable');

table.on('order', function () {
	// This will show: "Ordering on column 1 (asc)", for example
	var order = table.order();

	document.querySelector('#orderInfo').textContent =
		'Ordering on column ' + order[0][0] + ' (' + order[0][1] + ')';
});

Related

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