ColReorder provides the ability to specify a column ordering which is not that of the HTML (which typically you will want) through the parameter colReorder.order
. This is an array of
integers with the column ordering you want.
Start date | Age | Office | Position | Name | Salary |
---|---|---|---|---|---|
Start date | Age | Office | Position | Name | Salary |
2008/11/28 | 33 | Tokyo | Accountant | Airi Satou | $162,700 |
2009/10/09 | 47 | London | Chief Executive Officer (CEO) | Angelica Ramos | $1,200,000 |
2009/01/12 | 66 | San Francisco | Junior Technical Author | Ashton Cox | $86,000 |
2012/10/13 | 41 | London | Software Engineer | Bradley Greer | $132,000 |
2011/06/07 | 28 | San Francisco | Software Engineer | Brenden Wagner | $206,850 |
2012/12/02 | 61 | New York | Integration Specialist | Brielle Williamson | $372,000 |
2011/05/03 | 38 | London | Software Engineer | Bruno Nash | $163,500 |
2011/12/12 | 21 | New York | Pre-Sales Support | Caesar Vance | $106,450 |
2011/12/06 | 46 | New York | Sales Assistant | Cara Stevens | $145,600 |
2012/03/29 | 22 | Edinburgh | Senior Javascript Developer | Cedric Kelly | $433,060 |
The Javascript shown below is used to initialise the table shown in this example:
$(document).ready(function() {
$('#example').dataTable( {
colReorder: {
order: [ 4, 3, 2, 1, 0, 5 ]
}
} );
} );
In addition to the above code, the following Javascript library files are loaded for use in this example:
The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:
This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The additional CSS used is shown below:
The following CSS library files are loaded for use in this example to provide the styling of the table:
This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is loaded.
The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side processing scripts can be written in any language, using the protocol described in the DataTables documentation.