<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
<script src="https://nightly.datatables.net/rowgroup/js/dataTables.rowGroup.js?_=bc3763029fa6dfaf4c947ef25f079107"></script>
<meta charset=utf-8 />
<title>DataTables - Multi-level Collapse / Expand</title>
</head>
<body>
<div class="container">
<table id="table_orders" class="display compact cell-border" style="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;
}
table.dataTable tr.dtrg-group.dtrg-level-0 td {
font-weight: bold;
}
table.dataTable tr.dtrg-group td {
background-color: #e0e0e0;
}
table.dataTable tr.dtrg-group.dtrg-level-1 td:first-child{
padding-left: 2em;
}
table.dataTable tr.dtrg-group.dtrg-level-1 td{
background-color: #f0f0f0;
padding-top: 0.25em;
padding-bottom: 0.25em;
}
table.dataTable tr.dtrg-group.dtrg-level-2 td:first-child {
padding-left: 3em;
}
table.dataTable tr.dtrg-group.dtrg-level-2 td {
background-color: #fff0f0;
}
table.dataTable.compact tbody tr td.order_id {
padding-left: 4em;
}
var data = [{"webmaster":"Tiger Nixon","offer_name":"Power Bank Solar","arcdate":"2020-06-19","order_id":1358639},{"webmaster":"Tiger Nixon","offer_name":"GERBER Bear Grylls","arcdate":"2020-06-19","order_id":1358587},{"webmaster":"Tiger Nixon","offer_name":"GERBER Bear Grylls","arcdate":"2020-06-19","order_id":1358765},{"webmaster":"Tiger Nixon","offer_name":"GERBER Bear Grylls","arcdate":"2020-06-20","order_id":1358910},{"webmaster":"Tiger Nixon","offer_name":"GERBER Bear Grylls","arcdate":"2020-06-20","order_id":1358911},{"webmaster":"Tiger Nixon","offer_name":"GERBER Bear Grylls","arcdate":"2020-06-20","order_id":1359035},{"webmaster":"Tiger Nixon","offer_name":"GERBER Bear Grylls","arcdate":"2020-06-20","order_id":1359131},{"webmaster":"Tiger Nixon","offer_name":"GERBER Bear Grylls","arcdate":"2020-06-20","order_id":1359194},{"webmaster":"Tiger Nixon","offer_name":"Туристический гамак","arcdate":"2020-06-19","order_id":1358762},{"webmaster":"Sonya Frost","offer_name":"A-Plus 4","arcdate":"2020-06-19","order_id":1358666},{"webmaster":"Sonya Frost","offer_name":"Royal Queen","arcdate":"2020-06-19","order_id":1358589},{"webmaster":"Sonya Frost","offer_name":"Royal Queen","arcdate":"2020-06-19","order_id":1358622},{"webmaster":"Sonya Frost","offer_name":"Royal Queen","arcdate":"2020-06-19","order_id":1358708},{"webmaster":"Sonya Frost","offer_name":"Royal Queen","arcdate":"2020-06-19","order_id":1358713},{"webmaster":"Sonya Frost","offer_name":"Royal Queen","arcdate":"2020-06-19","order_id":1358797}];
$(document).ready(function() {
var collapsedGroups = [];
var groupParent = [];
var counter = 1;
var table = $('#table_orders').DataTable({
data: data,
columns: [
{data: 'webmaster', title:'webmaster'},
{data: 'offer_name', title: 'offer_name'},
{data: 'arcdate', title: 'arcdate'},
{data: 'order_id', title: 'User / Offer / Date / Order', class: 'order_id'},
],
order: [[0, 'asc'], [1, 'asc'], [2, 'asc']],
columnDefs: [ {
targets: [ 0, 1, 2],
visible: false
} ],
stripeClasses: [],
paging: false,
searching: false,
rowGroup: {
dataSrc: ['webmaster', 'offer_name', 'arcdate'],
startRender: function(rows, group, level) {
groupParent[level] = group;
var groupAll = '';
for (var i = 0; i < level; i++) {
groupAll += groupParent[i];
if (collapsedGroups[groupAll])
{
return;
}
}
groupAll += group;
if ((typeof(collapsedGroups[groupAll]) == 'undefined') || (collapsedGroups[groupAll] === null)) {collapsedGroups[groupAll] = true;} //True = Start collapsed. False = Start expanded.
var collapsed = collapsedGroups[groupAll];
rows.nodes().each(function(r) {r.style.display = (collapsed ? 'none' : '');});
return $('<tr/>').append('<td>' + counter++ + ' ' + group + '</td>').append('<td></td>').attr('data-name', groupAll).toggleClass('collapsed', collapsed);
},
initComplete: function() {
counter = 1;
}
}
})
.on('draw', function() {
counter = 1;
});
$('#table_orders tbody').on('click', 'tr.dtrg-start', 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. |