1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "fnSetColumnVis" );
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 "Can hide one column and it removes td column from DOM",
19 $('#example').dataTable();
20 $('#example').dataTable().fnSetColumnVis( 1, false );
22 function () { return $('#example tbody tr:eq(0) td').length == 4; }
26 "Can hide one column and it removes thead th column from DOM",
28 function () { return $('#example thead tr:eq(0) th').length == 4; }
32 "Can hide one column and it removes tfoot th column from DOM",
34 function () { return $('#example tfoot tr:eq(0) th').length == 4; }
38 "The correct thead column has been hidden",
41 var jqNodes = $('#example thead tr:eq(0) th');
43 jqNodes[0].innerHTML == "Rendering engine" &&
44 jqNodes[1].innerHTML == "Platform(s)" &&
45 jqNodes[2].innerHTML == "Engine version" &&
46 jqNodes[3].innerHTML == "CSS grade";
52 "The correct tbody column has been hidden",
54 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } );
57 var jqNodes = $('#example tbody tr:eq(0) td');
59 jqNodes[0].innerHTML == "Gecko" &&
60 jqNodes[1].innerHTML == "Gnome" &&
61 jqNodes[2].innerHTML == "1.8" &&
62 jqNodes[3].innerHTML == "A";
69 "Can hide multiple columns and it removes td column from DOM",
72 $('#example').dataTable();
73 $('#example').dataTable().fnSetColumnVis( 1, false );
74 $('#example').dataTable().fnSetColumnVis( 2, false );
75 $('#example').dataTable().fnSetColumnVis( 4, false );
77 function () { return $('#example tbody tr:eq(0) td').length == 2; }
81 "Multiple hide - removes thead th column from DOM",
83 function () { return $('#example thead tr:eq(0) th').length == 2; }
87 "Multiple hide - removes tfoot th column from DOM",
89 function () { return $('#example tfoot tr:eq(0) th').length == 2; }
93 "Multiple hide - the correct thead columns have been hidden",
96 var jqNodes = $('#example thead tr:eq(0) th');
98 jqNodes[0].innerHTML == "Rendering engine" &&
99 jqNodes[1].innerHTML == "Engine version"
105 "Multiple hide - the correct tbody columns have been hidden",
107 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } );
110 var jqNodes = $('#example tbody tr:eq(0) td');
112 jqNodes[0].innerHTML == "Gecko" &&
113 jqNodes[1].innerHTML == "1"