With DataTables you can alter the sorting characteristics of the table at initialisation time. Using the aaSorting initialisation parameter, you can get the table exactly how you want to present the information. The aaSorting parameter is an array of arrays where the first value is the column to sort on, and the second is 'asc' or 'desc' as required (it is a double array for multi-column sorting). The table below is sorted (descending) by the CSS grade. Note also that the 'Engine version' column is automatically detected as a numeric column and sorted accordingly. Finally, also note that "asSorting" has been defined for the column in question for this example. The reason for this is that DataTables uses ["asc","desc"] for sorting order by default, but we would in this case prefer "desc" to be given first priority.
Rendering engine | Browser | Platform(s) | Engine version | CSS grade |
---|---|---|---|---|
Rendering engine | Browser | Platform(s) | Engine version | CSS grade |
Trident | Internet Explorer 4.0 | Win 95+ | 4 | X |
Tasman | Internet Explorer 4.5 | Mac OS 8-9 | - | X |
Misc | Dillo 0.8 | Embedded devices | - | X |
Misc | Links | Text only | - | X |
Misc | Lynx | Text only | - | X |
Other browsers | All others | - | - | U |
Presto | Nintendo DS browser | Nintendo DS | 8.5 | C/A1 |
Trident | Internet Explorer 5.0 | Win 95+ | 5 | C |
KHTML | Konqureror 3.1 | KDE 3.1 | 3.1 | C |
Tasman | Internet Explorer 5.1 | Mac OS 7.6-9 | 1 | C |
1 2 3 4 5 | $(document).ready( function () { $( '#example' ).dataTable( { "aaSorting" : [[ 4, "desc" ]] } ); } ); |