colReorder.order()

Since: ColReorder 1.2.0

Get / set column order. Please note - this property requires the ColReorder extension for DataTables.

Description

This method provides the ability to get the current column order of a DataTable and also to set a new order.

The reorder triggered by this method is immediate and there is no requirement to redraw the table.

Types

function colReorder.order()

Description:

Get the current column order.

Returns:

Returns an array of column indexes. The column index given is the original column index, with its new position defined by the location in the returned array.

function colReorder.order( order [, originalIndexes ] )

Description:

Set the column order.

Parameters:
Returns:

DataTables API instance for chaining

Examples

Reverse the order of the columns in the table on a button click:

var table = $('#example').DataTable( {
	colReorder: true
} );

$('#reverse').click( function (e) {
	table.colReorder.order( [ 5, 4, 3, 2, 1, 0 ] );
} );

Restore the original order, regardless of any ordering applied (by passing the second parameter as true):

var table = $('#example').DataTable( {
	colReorder: true
} );

$('#reverse').click( function (e) {
	table.colReorder.order( [ 0, 1, 2, 3, 4, 5 ], true );
} );