Skip to content

Instantly share code, notes, and snippets.

@iksela
Created January 12, 2011 10:09
Show Gist options
  • Save iksela/775967 to your computer and use it in GitHub Desktop.
Save iksela/775967 to your computer and use it in GitHub Desktop.
This file will be used to overload some styles and format the print output.
$('#tableID').dataTable({
"bProcessing": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": 'ajax/datatables.php',
"oLanguage": { "sUrl": "../res/js/dataTables.fr.txt" },
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "../res/swf/copy_cvs_xls_pdf.swf",
"aButtons": [
{
"sExtends": "print",
"sButtonText": "Imprimer",
/* We add a click function to switch the media type of the print CSS, and add a listener on the Escape key to switch it back. */
"fnClick": function() {
$('#css_print').attr('media', 'all');
$(document).keydown(function(e){
if (e.keyCode == 27) {
$('#css_print').attr('media', 'print');
}
});
}
},
]
}
});
<!-- we set the media type to "print" for our special print CSS, and give it and ID. -->
<link rel="stylesheet" href="../res/css/print.css" type="text/css" media="print" id="css_print" />
<!-- we set the media type of the DataTables css to "all" -->
<link rel="stylesheet" href="../res/css/demo_table_jui.css" type="text/css" media="all" />
table {
width: 100%;
}
.DataTables_sort_wrapper {
font-weight: bold;
}
tr, td, th {
border: 1px solid #000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment