{hero}

colReorder.enable()

Since: ColReorder 1.5.0

Enable or disable ColReorder's interactions.
Please note - this property requires the ColReorder extension for DataTables.

Description

This method can be used to enable and disable the ColReorder end user interaction with a DataTable. In its simplest form it can be used to enable ColReorder, but it can also be used to disable it using the optional parameter. This is useful to be able to toggle the enablement state using a ternary operator or some external variable.

Please note that in order to be able to enable ColReorder, the colReorder option must be specified in the DataTable initialisation. This method cannot be used to enable ColReorder if colReorder has not be used.

Type

function colReorder.enable( [ flag ] )

Description:

Enable and disable user ability to reorder columns in a table.

Parameters:
Returns:

DataTables API instance

Example

Enable / disable column reordering using buttons:

var table = new DataTable('#myTable', {
	colReorder: true
});

$('#enableReordering').on('click', function () {
	table.colReorder.enable(true);
});

$('#disableReordering').on('click', function () {
	table.colReorder.enable(false);
});

Related

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