1 // DATA_TEMPLATE: complex_header_2
2 oTest.fnStart( "aoColumns.bVisible with complex headers" );
4 $(document).ready( function () {
5 /* Check the default */
6 var oTable = $('#example').dataTable();
7 var oSettings = oTable.fnSettings();
10 "All columns are visible by default",
12 function () { return $('#example tbody tr:eq(0) td').length == 5; }
16 "Hide the first column",
19 $('#example').dataTable( {
21 { "bVisible": false },
29 function () { return $('#example tbody tr:eq(0) td').length == 4; }
33 "First cell is '2' - first column hidden",
35 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "2"; }
39 "First cell has colspan of 3",
41 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('colspan') == 3; }
45 "First cell has rowspan of 2",
47 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('rowspan') == 2; }
51 "First cell in last column is '11'",
53 function () { return $('#example thead tr:eq(4) th:eq(0)').html() == 11; }
57 "First cell in last column has been truncated to one column",
59 function () { return $('#example thead tr:eq(4) th:eq(0)')[0].getAttribute('colspan') == 1; }
64 "Hide the second column",
67 $('#example').dataTable( {
70 { "bVisible": false },
77 function () { return $('#example tbody tr:eq(0) td').length == 4; }
81 "First cell is '1' - second column hidden",
83 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "1"; }
87 "Second cell is '2' - second column hidden",
89 function () { return $('#example thead tr:eq(0) th:eq(1)').html() == "2"; }
93 "First cell in fourth row is '10' (visibly the first) - second column hidden",
95 function () { return $('#example thead tr:eq(3) th:eq(0)').html() == "10"; }
99 "First cell has colspan of 1",
101 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('colspan') == 1; }
105 "Second cell has colspan of 2",
107 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('colspan') == 2; }
111 "First cell has rowspan of 1",
113 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('rowspan') == 1; }
117 "Second cell has rowspan of 2",
119 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('rowspan') == 2; }
123 "First cell in last column is '11'",
125 function () { return $('#example thead tr:eq(4) th:eq(0)').html() == 11; }
129 "First cell in last column has been truncated to one column",
131 function () { return $('#example thead tr:eq(4) th:eq(0)')[0].getAttribute('colspan') == 1; }
136 "Hide the first two columns",
138 oSession.fnRestore();
139 $('#example').dataTable( {
141 { "bVisible": false },
142 { "bVisible": false },
149 function () { return $('#example tbody tr:eq(0) td').length == 3; }
153 "First cell is '2' - first two columns hidden",
155 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "2"; }
159 "Second cell is '3' - first two columns hidden",
161 function () { return $('#example thead tr:eq(0) th:eq(1)').html() == "3"; }
165 "First cell in third row is '6' - first two columns hidden",
167 function () { return $('#example thead tr:eq(2) th:eq(0)').html() == "6"; }
171 "First cell has colspan of 2",
173 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('colspan') == 2; }
177 "First cell has rowspan of 2",
179 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('rowspan') == 2; }
183 "Second cell has rowspan of 1",
185 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('rowspan') == 1; }
189 "First cell in last column is '12'",
191 function () { return $('#example thead tr:eq(4) th:eq(0)').html() == 12; }
196 "Hide the third column",
198 oSession.fnRestore();
199 $('#example').dataTable( {
203 { "bVisible": false },
209 function () { return $('#example tbody tr:eq(0) td').length == 4; }
213 "First cell is '1' - third column hidden",
215 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "1"; }
219 "Second cell is '2' - third column hidden",
221 function () { return $('#example thead tr:eq(0) th:eq(1)').html() == "2"; }
225 "First cell (visible second) in third row is '6' - third column hidden",
227 function () { return $('#example thead tr:eq(2) th:eq(0)').html() == "6"; }
231 "Second cell has colspan of 2",
233 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('colspan') == 2; }
237 "Second cell has rowspan of 2",
239 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('rowspan') == 2; }
243 "Third row first cell (second visible) colspan is 1",
245 function () { return $('#example thead tr:eq(2) th:eq(0)')[0].getAttribute('colspan') == 1; }
249 "Third row second cell (third visible) value is 7",
251 function () { return $('#example thead tr:eq(2) th:eq(1)').html() == "7"; }
255 "Third row second cell (third visible) colspan is 1",
257 function () { return $('#example thead tr:eq(2) th:eq(1)')[0].getAttribute('colspan') == 1; }
261 "Third row second cell (third visible) rowspan is 3",
263 function () { return $('#example thead tr:eq(2) th:eq(1)')[0].getAttribute('rowspan') == 3; }