0
|
1 // DATA_TEMPLATE: empty_table
|
|
2 oTest.fnStart( "aaSorting" );
|
|
3
|
|
4 $(document).ready( function () {
|
|
5 /* Check the default */
|
|
6 var oTable = $('#example').dataTable( {
|
|
7 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
8 "bDeferRender": true
|
|
9 } );
|
|
10 var oSettings = oTable.fnSettings();
|
|
11
|
|
12 oTest.fnWaitTest(
|
|
13 "Default sorting is single column",
|
|
14 null,
|
|
15 function () {
|
|
16 return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object';
|
|
17 }
|
|
18 );
|
|
19
|
|
20 oTest.fnWaitTest(
|
|
21 "Default sorting is first column asc",
|
|
22 null,
|
|
23 function () {
|
|
24 return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 &&
|
|
25 oSettings.aaSorting[0][1] == 'asc';
|
|
26 }
|
|
27 );
|
|
28
|
|
29 oTest.fnWaitTest(
|
|
30 "Sorting is applied",
|
|
31 null,
|
|
32 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
|
|
33 );
|
|
34
|
|
35
|
|
36 oTest.fnWaitTest(
|
|
37 "Custom sorting on single string column asc",
|
|
38 function () {
|
|
39 oSession.fnRestore();
|
|
40 $('#example').dataTable( {
|
|
41 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
42 "bDeferRender": true,
|
|
43 "aaSorting": [['1','asc']]
|
|
44 } );
|
|
45 },
|
|
46 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
|
|
47 );
|
|
48
|
|
49
|
|
50 oTest.fnWaitTest(
|
|
51 "Custom sorting on single string column desc",
|
|
52 function () {
|
|
53 oSession.fnRestore();
|
|
54 $('#example').dataTable( {
|
|
55 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
56 "bDeferRender": true,
|
|
57 "aaSorting": [['1','desc']]
|
|
58 } );
|
|
59 },
|
|
60 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
|
61 );
|
|
62
|
|
63
|
|
64 oTest.fnWaitTest(
|
|
65 "Custom sorting on single int column asc",
|
|
66 function () {
|
|
67 oSession.fnRestore();
|
|
68 $('#example').dataTable( {
|
|
69 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
70 "bDeferRender": true,
|
|
71 "aaSorting": [['1','asc']]
|
|
72 } );
|
|
73 },
|
|
74 function () { return $('#example tbody td:eq(3)').html() == "-"; }
|
|
75 );
|
|
76
|
|
77
|
|
78 oTest.fnWaitTest(
|
|
79 "Custom sorting on single int column desc",
|
|
80 function () {
|
|
81 oSession.fnRestore();
|
|
82 $('#example').dataTable( {
|
|
83 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
84 "bDeferRender": true,
|
|
85 "aaSorting": [['1','desc']]
|
|
86 } );
|
|
87 },
|
|
88 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
|
89 );
|
|
90
|
|
91
|
|
92 oTest.fnWaitTest(
|
|
93 "Multi-column sorting (2 column) - string asc / string asc",
|
|
94 function () {
|
|
95 oSession.fnRestore();
|
|
96 $('#example').dataTable( {
|
|
97 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
98 "bDeferRender": true,
|
|
99 "aaSorting": [['0','asc'], ['1','asc']]
|
|
100 } );
|
|
101 },
|
|
102 function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; }
|
|
103 );
|
|
104
|
|
105 oTest.fnWaitTest(
|
|
106 "Multi-column sorting (2 column) - string asc / string desc",
|
|
107 function () {
|
|
108 oSession.fnRestore();
|
|
109 $('#example').dataTable( {
|
|
110 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
111 "bDeferRender": true,
|
|
112 "aaSorting": [['0','asc'], ['1','desc']]
|
|
113 } );
|
|
114 },
|
|
115 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
|
|
116 );
|
|
117
|
|
118 oTest.fnWaitTest(
|
|
119 "Multi-column sorting (2 column) - string desc / string asc",
|
|
120 function () {
|
|
121 oSession.fnRestore();
|
|
122 $('#example').dataTable( {
|
|
123 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
124 "bDeferRender": true,
|
|
125 "aaSorting": [['0','desc'], ['1','asc']]
|
|
126 } );
|
|
127 },
|
|
128 function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; }
|
|
129 );
|
|
130
|
|
131 oTest.fnWaitTest(
|
|
132 "Multi-column sorting (2 column) - string desc / string desc",
|
|
133 function () {
|
|
134 oSession.fnRestore();
|
|
135 $('#example').dataTable( {
|
|
136 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
137 "bDeferRender": true,
|
|
138 "aaSorting": [['0','desc'], ['1','desc']]
|
|
139 } );
|
|
140 },
|
|
141 function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; }
|
|
142 );
|
|
143
|
|
144
|
|
145 oTest.fnWaitTest(
|
|
146 "Multi-column sorting (2 column) - string asc / int asc",
|
|
147 function () {
|
|
148 oSession.fnRestore();
|
|
149 $('#example').dataTable( {
|
|
150 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
151 "bDeferRender": true,
|
|
152 "aaSorting": [['0','asc'], ['3','asc']]
|
|
153 } );
|
|
154 },
|
|
155 function () { return $('#example tbody td:eq(3)').html() == "1"; }
|
|
156 );
|
|
157
|
|
158 oTest.fnWaitTest(
|
|
159 "Multi-column sorting (2 column) - string asc / int desc",
|
|
160 function () {
|
|
161 oSession.fnRestore();
|
|
162 $('#example').dataTable( {
|
|
163 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
164 "bDeferRender": true,
|
|
165 "aaSorting": [['0','asc'], ['3','desc']]
|
|
166 } );
|
|
167 },
|
|
168 function () { return $('#example tbody td:eq(3)').html() == "1.9"; }
|
|
169 );
|
|
170
|
|
171 oTest.fnWaitTest(
|
|
172 "Multi-column sorting (2 column) - string desc / int asc",
|
|
173 function () {
|
|
174 oSession.fnRestore();
|
|
175 $('#example').dataTable( {
|
|
176 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
177 "bDeferRender": true,
|
|
178 "aaSorting": [['0','desc'], ['3','asc']]
|
|
179 } );
|
|
180 },
|
|
181 function () { return $('#example tbody td:eq(3)').html() == "125.5"; }
|
|
182 );
|
|
183
|
|
184 oTest.fnWaitTest(
|
|
185 "Multi-column sorting (2 column) - string desc / int desc",
|
|
186 function () {
|
|
187 oSession.fnRestore();
|
|
188 $('#example').dataTable( {
|
|
189 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
190 "bDeferRender": true,
|
|
191 "aaSorting": [['0','desc'], ['3','desc']]
|
|
192 } );
|
|
193 },
|
|
194 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
|
|
195 );
|
|
196
|
|
197 oTest.fnWaitTest(
|
|
198 "Multi-column sorting (3 column) - string asc / int asc / string asc",
|
|
199 function () {
|
|
200 oSession.fnRestore();
|
|
201 $('#example').dataTable( {
|
|
202 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
|
|
203 "bDeferRender": true,
|
|
204 "aaSorting": [['0','asc'], ['3','asc'], ['1','asc']]
|
|
205 } );
|
|
206 },
|
|
207 function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; }
|
|
208 );
|
|
209
|
|
210
|
|
211 oTest.fnComplete();
|
|
212 } ); |