<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.11.3/b-2.0.1/b-colvis-2.0.1/b-html5-2.0.1/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.11.3/b-2.0.1/b-html5-2.0.1/datatables.min.js"></script>
<meta charset=utf-8 />
<title>DataTables - JS Bin</title>
</head>
<body>
<div class="container">
<table id="haddy" class="display nowrap" width="100%">
</table>
</div>
</body>
</html>
body {
font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
color: #333;
background-color: #fff;
}
$(document).ready( function () {
var scol = '[{"data":"1st","title":"1st","mData":"1st","sTitle":"1st"},{"data":"2end","title":"2end","mData":"2end","sTitle":"2end"},{"data":"3rd","title":"3rd","mData":"3rd","sTitle":"3rd"},{"data":"4th","title":"4th","mData":"4th","sTitle":"4th"},{"data":"5th","title":"5th","mData":"5th","sTitle":"5th"},{"data":"6th","title":"6th","mData":"6th","sTitle":"6th"}]';
var sData = '[{ "ReceiptDate": "2021/07/18", "1st": 1, "2end": 0, "3rd": 100, "4th": 1, "5th": 1, "6th": 0, "7th": 1}, { "ReceiptDate": "2021/07/19", "1st": 5, "2end": 2, "3rd": 60, "4th": 1, "5th": 1, "6th": 40, "7th": 3}, { "ReceiptDate": "2021/08/02", "1st": 3, "2end": 1, "3rd": 67, "4th": 0, "5th": 0, "6th": 67, "7th": 1}, { "ReceiptDate": "2021/08/30", "1st": 1, "2end": 0, "3rd": 100, "4th": 0, "5th": 0, "6th": 100, "7th": 0}]';
var dataColumn = JSON.parse(scol);
var dataValue = JSON.parse(sData);
var footer = '<tfoot id="rptFooter"><tr class="dataFooter">';
$.each(dataColumn, function (i, j) {
footer = footer + '<th></th>';
});
$('#haddy').append(footer + '</tr></tfoot>');
$('#haddy').DataTable({
dom: 'lBfrtipF',
"data": dataValue,
"columns": dataColumn,
"buttons": [
{
extend: 'copyHtml5',
text: 'Copy',
titleAttr: 'Copy',
title: 'Haddy',
exportOptions: {
columns: ':visible'
},
footer: true
},
{
extend: 'excelHtml5',
text: 'Excel',
titleAttr: 'Excel',
title: 'Haddy',
footer: true,
exportOptions: {
columns: ':visible'
}
}
],
"fnFooterCallback": function (tfoot, data, start, end, display) {
var api = this.api();
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
api.columns().every(function () {
// Total over all pages
total = this
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( this.footer() ).html(
total
);
});
}
});
} );
You can jump to the latest bin by adding /latest
to your URL
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + [ | Indents selected lines |
ctrl + ] | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Clone Bin |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |