1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "aoColumns.bSortable" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
/* Check the default */ |
6 |
var oTable = $('#example').dataTable( { |
7 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt" |
8 |
} ); |
9 |
var oSettings = oTable.fnSettings(); |
10 |
|
11 |
oTest.fnWaitTest( |
12 |
"All columns are sortable by default", |
13 |
function () { $('#example thead th:eq(1)').click(); }, |
14 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; } |
15 |
); |
16 |
|
17 |
oTest.fnWaitTest( |
18 |
"Can disable sorting from one column", |
19 |
function () { |
20 |
oSession.fnRestore(); |
21 |
$('#example').dataTable( { |
22 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
23 |
"aoColumns": [ |
24 |
null, |
25 |
{ "bSortable": false }, |
26 |
null, |
27 |
null, |
28 |
null |
29 |
] |
30 |
} ); |
31 |
$('#example thead th:eq(1)').click(); |
32 |
}, |
33 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } |
34 |
); |
35 |
|
36 |
oTest.fnWaitTest( |
37 |
"Disabled column has no sorting class", |
38 |
null, |
39 |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; } |
40 |
); |
41 |
|
42 |
oTest.fnWaitTest( |
43 |
"Other columns can still sort", |
44 |
function () { |
45 |
$('#example thead th:eq(4)').click(); |
46 |
$('#example thead th:eq(4)').click(); |
47 |
}, |
48 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } |
49 |
); |
50 |
|
51 |
oTest.fnWaitTest( |
52 |
"Disable sorting on multiple columns - no sorting classes", |
53 |
function () { |
54 |
oSession.fnRestore(); |
55 |
$('#example').dataTable( { |
56 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
57 |
"aoColumns": [ |
58 |
null, |
59 |
{ "bSortable": false }, |
60 |
null, |
61 |
{ "bSortable": false }, |
62 |
null |
63 |
] |
64 |
} ); |
65 |
}, |
66 |
function () { |
67 |
var bReturn = |
68 |
$('#example thead th:eq(1)').hasClass("sorting") || |
69 |
$('#example thead th:eq(3)').hasClass("sorting") |
70 |
return bReturn == false; |
71 |
} |
72 |
); |
73 |
|
74 |
oTest.fnWaitTest( |
75 |
"Sorting on disabled column 1 has no effect", |
76 |
function () { |
77 |
$('#example thead th:eq(1)').click(); |
78 |
}, |
79 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } |
80 |
); |
81 |
|
82 |
oTest.fnWaitTest( |
83 |
"Sorting on disabled column 2 has no effect", |
84 |
function () { |
85 |
$('#example thead th:eq(3)').click(); |
86 |
}, |
87 |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } |
88 |
); |
89 |
|
90 |
oTest.fnWaitTest( |
91 |
"Second sort on disabled column 2 has no effect", |
92 |
function () { |
93 |
$('#example thead th:eq(3)').click(); |
94 |
}, |
95 |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } |
96 |
); |
97 |
|
98 |
oTest.fnWaitTest( |
99 |
"Even with multiple disabled sorting columns other columns can still sort", |
100 |
function () { |
101 |
$('#example thead th:eq(4)').click(); |
102 |
$('#example thead th:eq(4)').click(); |
103 |
}, |
104 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } |
105 |
); |
106 |
|
107 |
|
108 |
oTest.fnComplete(); |
109 |
} ); |