1 |
// DATA_TEMPLATE: js_data |
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 |
"aaData": gaaData, |
10 |
"aoColumns": [ |
11 |
null, |
12 |
{ "iDataSort": 4 }, |
13 |
null, |
14 |
null, |
15 |
null |
16 |
] |
17 |
} ); |
18 |
var oSettings = oTable.fnSettings(); |
19 |
|
20 |
oTest.fnTest( |
21 |
"Sorting on first column is uneffected", |
22 |
null, |
23 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } |
24 |
); |
25 |
|
26 |
oTest.fnTest( |
27 |
"Sorting on second column is the order of the fifth", |
28 |
function () { $('#example thead th:eq(1)').click(); }, |
29 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
30 |
); |
31 |
|
32 |
oTest.fnTest( |
33 |
"Reserve sorting on second column uses fifth column as well", |
34 |
function () { $('#example thead th:eq(1)').click(); }, |
35 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } |
36 |
); |
37 |
|
38 |
oTest.fnTest( |
39 |
"Sorting on 5th column retains it's own sorting", |
40 |
function () { $('#example thead th:eq(4)').click(); }, |
41 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
42 |
); |
43 |
|
44 |
|
45 |
oTest.fnTest( |
46 |
"Use 2nd col for sorting 5th col and via-versa - no effect on first col sorting", |
47 |
function () { |
48 |
mTmp = 0; |
49 |
oSession.fnRestore(); |
50 |
oTable = $('#example').dataTable( { |
51 |
"aaData": gaaData, |
52 |
"aoColumns": [ |
53 |
null, |
54 |
{ "iDataSort": 4 }, |
55 |
null, |
56 |
null, |
57 |
{ "iDataSort": 1 } |
58 |
] |
59 |
} ); |
60 |
}, |
61 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } |
62 |
); |
63 |
|
64 |
oTest.fnTest( |
65 |
"2nd col sorting uses fifth col", |
66 |
function () { $('#example thead th:eq(1)').click(); }, |
67 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } |
68 |
); |
69 |
|
70 |
oTest.fnTest( |
71 |
"2nd col sorting uses fifth col - reversed", |
72 |
function () { $('#example thead th:eq(1)').click(); }, |
73 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } |
74 |
); |
75 |
|
76 |
oTest.fnTest( |
77 |
"5th col sorting uses 2nd col", |
78 |
function () { $('#example thead th:eq(4)').click(); }, |
79 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } |
80 |
); |
81 |
|
82 |
oTest.fnTest( |
83 |
"5th col sorting uses 2nd col - reversed", |
84 |
function () { $('#example thead th:eq(4)').click(); }, |
85 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1'; } |
86 |
); |
87 |
|
88 |
|
89 |
oTest.fnComplete(); |
90 |
} ); |