<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="\main.css">
<title>Document</title>
<link href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<link href="https://code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="https://code.jquery.com/jquery-3.6.0.js" type="text/javascript"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.11.3/rg-1.1.4/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.11.3/rg-1.1.4/datatables.min.js"></script>
<link href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.dataTables.min.css" rel="stylesheet" type="text/css"/>
<script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js" type="text/javascript"></script>
<script type="text/javascript" src="\main.js"></script>
</head>
<body>
<table id="hserack_items" class = "table-responsive">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
</body>
</html>
.cell {
padding: 0px;
display: flex;
justify-content: center;
}
td {
border: 1px solid #000;
}
tr td:last-child {
width: 1%;
white-space: nowrap;
}
$(document).ready(function() {
var collapsedGroups = {};
var top = '';
var table = $('#hserack_items').DataTable({
responsive: {
details: {
display: $.fn.dataTable.Responsive.display.childRowImmediate,
type: 'none',
target: ''
}
},
data: [
{
"HSESHELF":"Shelf: 1",
"HOUSECTION":"S 7",
"CODE":"ABCD",
"LABLDATE":"11-29",
"NAME":"Christmas Bells",
"QTY":4,
"SCANNED":[
"12",
"12",
"12",
"12"
]
},
{
"HSESHELF":"Shelf: 2",
"HOUSECTION":"S10",
"CODE":"DEFG",
"LABLDATE":"11-29",
"NAME":"Christmas Bells",
"QTY":4,
"SCANNED":[
"12",
"12",
"12",
]
},
],
columns: [
{ data: "HSESHELF" },
{ data: "HOUSECTION" },
{
data: null,
render: function ( data, type, row, meta) {
let scanned_qty = row["SCANNED"].length;
let rendered_data = `${scanned_qty}/${row["QTY"]}`;
return rendered_data
},
},
{ data: "CODE",},
{ data: "LABLDATE" },
{ data: "NAME" },
{ data: "SCANNED" },
{ data: "QTY",
},
],
rowGroup: {
dataSrc: [ "HSESHELF", "HOUSECTION"],
startRender: function(rows, group,level) {
var all;
if (level === 0) {
top = group;
all = group;
} else {
// if parent collapsed, nothing to do
if (!!collapsedGroups[top]) {
return;
}
all = top + group;
}
// console.log(group,level,collapsedGroups);
var collapsed = !!collapsedGroups[all];
let count = 0;
rows.nodes().each(function(r) {
let elements = r.children[0].textContent.split("/");
if (elements[0]== elements[1]) {
count+= 1;
}
});
if (count == rows[0].length) {
collapsed = !collapsed;
}
rows.nodes().each(function(r) {
r.style.display = collapsed ? 'none' : '';
});
// Add category name to the <tr>. NOTE: Hardcoded colspan
return $('<tr/>')
.append('<td colspan="8">' + group + '</td>')
.attr('data-name', all)
.toggleClass('collapsed', collapsed);
},
},
"columnDefs": [
{ "width": "10%", "targets": 2 },
{
"targets": [0,1,6,7],
"visible": false,
}
],
paging: false,
// select: true,
"ordering": false,
});
table.on('draw', function () {
table.rows({page: 'current'}).every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
// Check to see if any of the rowGroup.dataSrc collapsable rows are collapsed
if (collapsedGroups[data.HSESHELF]) {
this.child.hide();
} else {
this.child.show();
}
} );
})
$('#hserack_items tbody').on('click', 'tr.dtrg-level-0', function () {
var name = $(this).data('name');
collapsedGroups[name] = !collapsedGroups[name];
table.draw(false);
}); })
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. |