1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aaSorting" );
4 $(document).ready( function () {
5 /* Check the default */
6 var oTable = $('#example').dataTable( {
8 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php"
10 var oSettings = oTable.fnSettings();
13 "Default sorting is single column",
16 return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object';
21 "Default sorting is first column asc",
24 return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 &&
25 oSettings.aaSorting[0][1] == 'asc';
32 function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; }
37 "Custom sorting on single string column asc",
40 $('#example').dataTable( {
42 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
43 "aaSorting": [['1','asc']]
46 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
51 "Custom sorting on single string column desc",
54 $('#example').dataTable( {
56 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
57 "aaSorting": [['1','desc']]
60 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
65 "Custom sorting on single int column asc",
68 $('#example').dataTable( {
70 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
71 "aaSorting": [['1','asc']]
74 function () { return $('#example tbody td:eq(3)').html() == "-"; }
79 "Custom sorting on single int column desc",
82 $('#example').dataTable( {
84 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
85 "aaSorting": [['1','desc']]
88 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
93 "Multi-column sorting (2 column) - string asc / string asc",
96 $('#example').dataTable( {
98 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
99 "aaSorting": [['0','asc'], ['1','asc']]
102 function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; }
106 "Multi-column sorting (2 column) - string asc / string desc",
108 oSession.fnRestore();
109 $('#example').dataTable( {
111 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
112 "aaSorting": [['0','asc'], ['1','desc']]
115 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
119 "Multi-column sorting (2 column) - string desc / string asc",
121 oSession.fnRestore();
122 $('#example').dataTable( {
124 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
125 "aaSorting": [['0','desc'], ['1','asc']]
128 function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; }
132 "Multi-column sorting (2 column) - string desc / string desc",
134 oSession.fnRestore();
135 $('#example').dataTable( {
137 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
138 "aaSorting": [['0','desc'], ['1','desc']]
141 function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; }
146 "Multi-column sorting (2 column) - string asc / int asc",
148 oSession.fnRestore();
149 $('#example').dataTable( {
151 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
152 "aaSorting": [['0','asc'], ['3','asc']]
155 function () { return $('#example tbody td:eq(3)').html() == "1"; }
159 "Multi-column sorting (2 column) - string asc / int desc",
161 oSession.fnRestore();
162 $('#example').dataTable( {
164 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
165 "aaSorting": [['0','asc'], ['3','desc']]
168 function () { return $('#example tbody td:eq(3)').html() == "1.9"; }
172 "Multi-column sorting (2 column) - string desc / int asc",
174 oSession.fnRestore();
175 $('#example').dataTable( {
177 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
178 "aaSorting": [['0','desc'], ['3','asc']]
181 function () { return $('#example tbody td:eq(3)').html() == "125.5"; }
185 "Multi-column sorting (2 column) - string desc / int desc",
187 oSession.fnRestore();
188 $('#example').dataTable( {
190 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
191 "aaSorting": [['0','desc'], ['3','desc']]
194 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
198 "Multi-column sorting (3 column) - string asc / int asc / string asc",
200 oSession.fnRestore();
201 $('#example').dataTable( {
203 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
204 "aaSorting": [['0','asc'], ['3','asc'], ['1','asc']]
207 function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; }