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