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