Select Git revision
-
David Sehnal authoredDavid Sehnal authored
show_hide.html 20.03 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/media/images/favicon.ico" />
<title>DataTables example</title>
<style type="text/css" title="currentStyle">
@import "../../media/css/demo_page.css";
@import "../../media/css/demo_table.css";
</style>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"bPaginate": false
} );
} );
function fnShowHide( iCol )
{
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = $('#example').dataTable();
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
</script>
</head>
<body id="dt_example">
<div id="container">
<div class="full_width big">
DataTables show and hide columns dynamically example
</div>
<h1>Preamble</h1>
<p>This example shows how you can make use of the fnSetColumnVis() API function to show and hide columns in a table dynamically, after the table has been initialised (we've also got scrolling enabled here, although that is not required for the API function to work).</p>
<a href="javascript:void(0);" onclick="fnShowHide(0);">Toggle column 1<br></a>
<a href="javascript:void(0);" onclick="fnShowHide(1);">Toggle column 2<br></a>
<a href="javascript:void(0);" onclick="fnShowHide(2);">Toggle column 3<br></a>
<a href="javascript:void(0);" onclick="fnShowHide(3);">Toggle column 4<br></a>
<a href="javascript:void(0);" onclick="fnShowHide(4);">Toggle column 5<br></a>
<h1>Live example</h1>
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th>Rendering engine</th>
<th>Browser</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
</thead>
<tbody>
<tr class="gradeX">
<td>Trident</td>
<td>Internet
Explorer 4.0</td>
<td>Win 95+</td>
<td class="center">4</td>
<td class="center">X</td>
</tr>
<tr class="gradeC">
<td>Trident</td>
<td>Internet