Bootstrap Table
by jimkennelly
HTML
<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<table id="dataTable">
<thead>
<tr>
<th data-field="name">Name</th>
<th data-field="stargazers_count">Stars</th>
<th data-field="forks_count">Forks</th>
<th data-field="description">Description</th>
</tr>
</thead>
</table>
CSS
.test1 { background-color:green;}
JavaScript
$table = $("#dataTable");
$table.bootstrapTable({
url: "https://api.myjson.com/bins/omz7e",
});
var beforePrint = function() {
console.log('Functionality to run before printing.');
$table.addClass('test1')
};
var afterPrint = function() {
console.log('Functionality to run after printing');
$table.removeClass('test1');
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
mediaQueryList.addListener(function(mql) {
if (mql.matches) {
beforePrint();
} else {
afterPrint();
}
});
}
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;