1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "aoColumns.iDataSort" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
/* Should know that sorting already works by default from other tests, so we can jump |
6 |
* right in here |
7 |
*/ |
8 |
var oTable = $('#example').dataTable( { |
9 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
10 |
"bDeferRender": true, |
11 |
"aoColumns": [ |
12 |
null, |
13 |
{ "iDataSort": 4 }, |
14 |
null, |
15 |
null, |
16 |
null |
17 |
] |
18 |
} ); |
19 |
var oSettings = oTable.fnSettings(); |
20 |
|
21 |
oTest.fnWaitTest( |
22 |
"Sorting on first column is uneffected", |
23 |
null, |
24 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } |
25 |
); |
26 |
|
27 |
oTest.fnWaitTest( |
28 |
"Sorting on second column is the order of the fifth", |
29 |
function () { $('#example thead th:eq(1)').click(); }, |
30 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
31 |
); |
32 |
|
33 |
oTest.fnWaitTest( |
34 |
"Reserve sorting on second column uses fifth column as well", |
35 |
function () { $('#example thead th:eq(1)').click(); }, |
36 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } |
37 |
); |
38 |
|
39 |
oTest.fnWaitTest( |
40 |
"Sorting on 5th column retains it's own sorting", |
41 |
function () { $('#example thead th:eq(4)').click(); }, |
42 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
43 |
); |
44 |
|
45 |
|
46 |
oTest.fnWaitTest( |
47 |
"Use 2nd col for sorting 5th col and via-versa - no effect on first col sorting", |
48 |
function () { |
49 |
mTmp = 0; |
50 |
oSession.fnRestore(); |
51 |
oTable = $('#example').dataTable( { |
52 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
53 |
"bDeferRender": true, |
54 |
"aoColumns": [ |
55 |
null, |
56 |
{ "iDataSort": 4 }, |
57 |
null, |
58 |
null, |
59 |
{ "iDataSort": 1 } |
60 |
] |
61 |
} ); |
62 |
}, |
63 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } |
64 |
); |
65 |
|
66 |
oTest.fnWaitTest( |
67 |
"2nd col sorting uses fifth col", |
68 |
function () { $('#example thead th:eq(1)').click(); }, |
69 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
70 |
); |
71 |
|
72 |
oTest.fnWaitTest( |
73 |
"2nd col sorting uses fifth col - reversed", |
74 |
function () { $('#example thead th:eq(1)').click(); }, |
75 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } |
76 |
); |
77 |
|
78 |
oTest.fnWaitTest( |
79 |
"5th col sorting uses 2nd col", |
80 |
function () { $('#example thead th:eq(4)').click(); }, |
81 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } |
82 |
); |
83 |
|
84 |
oTest.fnWaitTest( |
85 |
"5th col sorting uses 2nd col - reversed", |
86 |
function () { $('#example thead th:eq(4)').click(); }, |
87 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1'; } |
88 |
); |
89 |
|
90 |
|
91 |
oTest.fnComplete(); |
92 |
} ); |