colReorder
Enable and configure the ColReorder extension for DataTables.
Please note - this property requires the ColReorder extension for DataTables.
Description
ColReorder provides the option for end users to reorder columns in a DataTable by click and drag, or for yourself, the developer using DataTable, through the API.
This option provides the ability to enable and configure ColReorder for DataTables. In its simplest form as the boolean true
it will enable ColReorder with the default configuration options (as defined by $.fn.dataTable.ColReorder.defaults
). It can also be used as an object to provide custom configuration options as described below.
Please note that as with all other configuration options for ColReorder, this option is an extension to the default set of DataTables options. This property should be set in the DataTables initialisation object.
Types
boolean
- Description:
As a boolean value this property will enable ColReorder on the DataTable that is being created.
true
will enable ColReorder, whilefalse
will not.This is a short-cut option to enable ColReorder with the default configuration options. Customisations can be made by giving this parameter as an object, see below.
object
- Description:
If given as an object, ColReorder will be enabled on the target DataTable, with default values (
$.fn.dataTable.ColReorder.defaults
) extended, and potentially overwritten, by the options provided in this object. This is how ColReorder can be configured on an individual table basis, or through the defaults.
Default
- Value:
undefined
ColReorder will not be initialised by default
Examples
Enable ColReorder for a table:
new DataTable('#myTable', {
colReorder: true
});
Enable ColReorder with configuration options:
new DataTable('#myTable', {
colReorder: {
columns: ':not(:first-child)'
}
});