DataTables logo DataTables

This site contains the legacy documentation for DataTables v1.9 and earlier for reference only.
DataTables 1.9 was End Of Life in 2014. Do not use it for new work.
The current release of DataTables can always be found on DataTables.net.
ColReorder v1.1.0

Options

In general ColReorder doesn't require much initialisation, and as such doesn't provide any options. Having said that there are a couple of options as shown below.

Initialisation

Initialisation of ColReorder can be performed in one of two different ways:

  1. Using the DataTables sDom initialisation option and the parameter 'R' that ColReorder adds to DataTables. For example:
    $(document).ready( function () {
    	$('#example').dataTable( {
    		"sDom": 'Rlfrtip'
    	} );
    } );
  2. Using new $.fn.dataTable.ColReorder();:
    $(document).ready( function () {
    	var table = $('#example').DataTable();
    	new $.fn.dataTable.ColReorder( table );
    } );

ColReorder options

aiOrder or order Why two names?
Show details
This parameter provides the ability to reorder a table on initialisation of the DataTable. It's simply an array of column indexes, in the order that you wish them to be displayed in.
Default: null
Type: Array
Code example:
$(document).ready( function () {
	var oTable = $('#example').dataTable( {
		"sDom": 'Rlfrtip',
		"oColReorder": {
			"aiOrder": [ 4, 3, 2, 1, 0 ]
		}
	} );
} );


// DataTables 1.10 camelCase style
$(document).ready( function () {
	$('#example').dataTable( {
		"dom": 'Rlfrtip',
		"colReorder": {
			"order": [ 4, 3, 2, 1, 0 ]
		}
	} );
} );
fnReorderCallback or reorderCallback Why two names?
Show details
Callback function which can be used to perform actions when the columns have been reordered.
Default:
Input parameters: void
Return parameter: void
Code example:
$(document).ready( function () {
	var oTable = $('#example').dataTable( {
		"sDom": 'Rlfrtip',
		"oColReorder": {
			"fnReorderCallback": function () {
				alert('Columns reordered');
			}
		}
	} );
} );


// DataTables 1.10 camelCase style
$(document).ready( function () {
	$('#example').dataTable( {
		"dom": 'Rlfrtip',
		"colReorder": {
			"reorderCallback": function () {
				alert('Columns reordered');
			}
		}
	} );
} );
iFixedColumnsRight or fixedColumnsRight Why two names?
Show details
Indicate how many columns should be fixed in position (counting from the right). This will typically be 1 if used, but can be as high as you like.
Default: 0
Type: integer
Code example:
// Using the `oColReorder` option in the DataTables options object
$('#example').dataTable( {
    "sDom": 'Rlfrtip',
    "oColReorder": {
        "iFixedColumnsRight": 1
    }
} );


// Using `new` constructor
$('#example').dataTable()

new $.fn.dataTable.ColReorder( '#example', {
    "iFixedColumnsRight": 1
} );
iFixedColumns or fixedColumns Why two names?
Show details
Indicate how many columns should be fixed in position (counting from the left). This will typically be 1 if used, but can be as high as you like.
Default: 0
Type: Integer
Code example:
$(document).ready( function () {
	var oTable = $('#example').dataTable( {
		"sDom": 'Rlfrtip',
		"oColReorder": {
			"iFixedColumns": 1
		}
	} );
} );


// DataTables 1.10 camelCase style
$(document).ready( function () {
	$('#example').dataTable( {
		"dom": 'Rlfrtip',
		"colReorder": {
			"fixedColumns": 1
		}
	} );
} );