1 |
// DATA_TEMPLATE: dom_data |
2 |
oTest.fnStart( "aoColumns.bVisible" ); |
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 visible by default", |
11 |
null, |
12 |
function () { return $('#example tbody tr:eq(0) td').length == 5; } |
13 |
); |
14 |
|
15 |
oTest.fnTest( |
16 |
"Can hide one column and it removes td column from DOM", |
17 |
function () { |
18 |
oSession.fnRestore(); |
19 |
$('#example').dataTable( { |
20 |
"aoColumns": [ |
21 |
null, |
22 |
{ "bVisible": false }, |
23 |
null, |
24 |
null, |
25 |
null |
26 |
] |
27 |
} ); |
28 |
}, |
29 |
function () { return $('#example tbody tr:eq(0) td').length == 4; } |
30 |
); |
31 |
|
32 |
oTest.fnTest( |
33 |
"Can hide one column and it removes thead th column from DOM", |
34 |
null, |
35 |
function () { return $('#example thead tr:eq(0) th').length == 4; } |
36 |
); |
37 |
|
38 |
oTest.fnTest( |
39 |
"Can hide one column and it removes tfoot th column from DOM", |
40 |
null, |
41 |
function () { return $('#example tfoot tr:eq(0) th').length == 4; } |
42 |
); |
43 |
|
44 |
oTest.fnTest( |
45 |
"The correct thead column has been hidden", |
46 |
null, |
47 |
function () { |
48 |
var jqNodes = $('#example thead tr:eq(0) th'); |
49 |
var bReturn = |
50 |
jqNodes[0].innerHTML == "Rendering engine" && |
51 |
jqNodes[1].innerHTML == "Platform(s)" && |
52 |
jqNodes[2].innerHTML == "Engine version" && |
53 |
jqNodes[3].innerHTML == "CSS grade"; |
54 |
return bReturn; |
55 |
} |
56 |
); |
57 |
|
58 |
oTest.fnTest( |
59 |
"The correct tbody column has been hidden", |
60 |
function () { |
61 |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); |
62 |
}, |
63 |
function () { |
64 |
var jqNodes = $('#example tbody tr:eq(0) td'); |
65 |
var bReturn = |
66 |
jqNodes[0].innerHTML == "Gecko" && |
67 |
jqNodes[1].innerHTML == "Gnome" && |
68 |
jqNodes[2].innerHTML == "1.8" && |
69 |
jqNodes[3].innerHTML == "A"; |
70 |
return bReturn; |
71 |
} |
72 |
); |
73 |
|
74 |
|
75 |
oTest.fnTest( |
76 |
"Can hide multiple columns and it removes td column from DOM", |
77 |
function () { |
78 |
oSession.fnRestore(); |
79 |
$('#example').dataTable( { |
80 |
"aoColumns": [ |
81 |
null, |
82 |
{ "bVisible": false }, |
83 |
{ "bVisible": false }, |
84 |
null, |
85 |
{ "bVisible": false } |
86 |
] |
87 |
} ); |
88 |
}, |
89 |
function () { return $('#example tbody tr:eq(0) td').length == 2; } |
90 |
); |
91 |
|
92 |
oTest.fnTest( |
93 |
"Multiple hide - removes thead th column from DOM", |
94 |
null, |
95 |
function () { return $('#example thead tr:eq(0) th').length == 2; } |
96 |
); |
97 |
|
98 |
oTest.fnTest( |
99 |
"Multiple hide - removes tfoot th column from DOM", |
100 |
null, |
101 |
function () { return $('#example tfoot tr:eq(0) th').length == 2; } |
102 |
); |
103 |
|
104 |
oTest.fnTest( |
105 |
"Multiple hide - the correct thead columns have been hidden", |
106 |
null, |
107 |
function () { |
108 |
var jqNodes = $('#example thead tr:eq(0) th'); |
109 |
var bReturn = |
110 |
jqNodes[0].innerHTML == "Rendering engine" && |
111 |
jqNodes[1].innerHTML == "Engine version" |
112 |
return bReturn; |
113 |
} |
114 |
); |
115 |
|
116 |
oTest.fnTest( |
117 |
"Multiple hide - the correct tbody columns have been hidden", |
118 |
function () { |
119 |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); |
120 |
}, |
121 |
function () { |
122 |
var jqNodes = $('#example tbody tr:eq(0) td'); |
123 |
var bReturn = |
124 |
jqNodes[0].innerHTML == "Gecko" && |
125 |
jqNodes[1].innerHTML == "1" |
126 |
return bReturn; |
127 |
} |
128 |
); |
129 |
|
130 |
|
131 |
oTest.fnComplete(); |
132 |
} ); |