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