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 example with server-side processing

Preamble

Server-side processing can be exceptionally useful in DataTables when dealing with massive data sets, and ColReorder works with this as would be expected. There must be special consideration for the column ordering on the server-side script since the columns can be in an unexpected order. For this you can either choose to use the sName parameter for each column and take this into account in the server-side script (the parameter 'sColumns' is a comma separated string of these sName parameters).

Alternatively use the more flexible mDataProp option for each column. This allows you to use JSON objects which DataTables, so order doesn't matter like it would do in an array. Again the server-side script must take this into account through the mDataProp_{i} which is sent for each column (so the server knows which column is to be sorted on).

Live example

Rendering engine Browser Platform(s) Engine version CSS grade
Rendering engine Browser Platform(s) Engine version CSS grade

Examples

Initialisation code

$(document).ready( function () {
	var oTable = $('#example').dataTable( {
		"sDom": 'Rlfrtip',
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "../../examples/server_side/scripts/objects.php",
		"aoColumns": [
			{ "mDataProp": "engine" },
			{ "mDataProp": "browser" },
			{ "mDataProp": "platform" },
			{ "mDataProp": "version" },
			{ "mDataProp": "grade" }
		]
	} );
} );

Example JSON return from the server

{
"sEcho": 1,
"iTotalRecords": "57",
"iTotalDisplayRecords": "57",
"aaData": [
    {
        "engine": "Gecko",
        "browser": "Firefox 1.0",
        "platform": "Win 98+ / OSX.2+",
        "version": "1.7",
        "grade": "A"
    },
    {
        "engine": "Gecko",
        "browser": "Firefox 1.5",
        "platform": "Win 98+ / OSX.2+",
        "version": "1.8",
        "grade": "A"
    },
    ...
  ]
}