Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 247rahimab/d822afc63382ca38e11520e90785869e to your computer and use it in GitHub Desktop.
Save 247rahimab/d822afc63382ca38e11520e90785869e to your computer and use it in GitHub Desktop.
DataTable TableTools example exporting hidden column to PDF
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>DataTables TableTools PDF Export</title>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type='text/javascript' src="https://raw.github.com/DataTables/DataTables/master/media/js/jquery.dataTables.js"></script>
<script type='text/javascript' src="https://raw.github.com/DataTables/TableTools/master/media/js/TableTools.js"></script>
<script type='text/javascript' src="https://raw.github.com/DataTables/TableTools/master/media/js/ZeroClipboard.js"></script>
</head>
<body>
<script type='text/javascript'>//<![CDATA[
$(function() {
$('#data-table').dataTable({
"bJQueryUI":true,
"aaData":[
{
"col0": "John",
"col1": "Foo",
"col2": "m",
"col3": "1981-12-01"
},
{
"col0": "Mike",
"col1": "Johns",
"col2": "m",
"col3": "1991-03-12"
},
{
"col0": "Linda",
"col1": "Smith",
"col2": "f",
"col3": "1973-06-30"
}
],
"aoColumns":[
{
"mDataProp":"col0"
},
{
"mDataProp":"col1"
},
{
"mDataProp":"col2",
"bVisible":false
},
{
"mDataProp":"col3"
}
],
"sDom":'T<"clear">lfrtip',
"oTableTools": {
// this wan't work because of Flash security restrictions ?!
// "sSwfPath": "https://raw.github.com/DataTables/TableTools/master/media/swf/copy_csv_xls_pdf.swf",
// change the path to the .swf file
"sSwfPath":"/path/to/copy_csv_xls_pdf.swf",
"aButtons":[
{
"sExtends":"pdf",
"mColumns":[0, 1, 2, 3],
"sPdfOrientation":"landscape"
}
]
}
});
});//]]>
</script>
<h1>DataTables TableTools PDF Export</h1>
<div>
<table id="data-table">
<thead>
<tr>
<th class="col0">First name</th>
<th class="col1">Last name</th>
<th class="col2">Gender</th>
<th class="col3">Date</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment