{hero}

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 (the first parameter). Additionally, the events are triggered with the dt namespace. As such, to listen for this event, you must also use the dt namespace by simply appending .dt to your event name, as shown in the example below.

Type

function 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();

	$('#orderInfo').html(
		'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.