<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>
<meta charset=utf-8 />
<title>DataTables - JS Bin</title>
</head>
<body>
<div class="container">
<table class="display" cellspacing="0" width="100%" id="tablePianodicaricoMaster">
<tbody>
<tr><td class="dataTables_empty" colspan="5">Nessun risultato</td></tr>
</tbody>
</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;
}
td.details-control {
background: url('https://www.datatables.net/examples/resources/details_open.png') no-repeat center center;
cursor: pointer;
}
tr.shown td.details-control {
background: url('https://www.datatables.net/examples/resources/details_close.png') no-repeat center center;
}
var detailRows = [];
var lastPage = null;
function onRowDetailsClick(table) {
//console.log('DataTable > onRowDetailsClick [' + new Date() + "]");
var tr = $(this).closest('tr');
var row = $('#tablePianodicaricoMaster').DataTable().row(tr);
var rowData = row.data();
var idx = $.inArray(row.index(), detailRows);
//var _url = App.getGlobalWcfErgonPath() + "GetDtPianoDiCaricoDetail";
//var _data = JSON.stringify({ pCdDeposito: $("#pCdDeposito").val(), pDtConsegna: moment($('#pDtConsegna').closest('div.date-picker').datepicker('getDate')).format(), pCdGiro: rowData.CdGiro });
if (row.child.isShown()) {
tr.removeClass('shown');
row.child.hide();
// Remove from the 'open' array
detailRows.splice(row.index(), 1);
}
else {
tr.addClass('shown');
//row.child(format(row.data())).show();
row.child("<div class='wrapper loading'><div id='loadDetail" + rowData.CdGiro + "' class='elaborazione'>Elaborazione ...</div>" +
"<table class='table table-bordered table-hover child_table' cellspacing='0' id='tablePianodicaricoDetail" + rowData.CdGiro +
"' style='padding-left:50px;'><tbody></tbody></table></div>").show();
var detailsTableOpt = $('#tablePianodicaricoDetail' + rowData.CdGiro).dataTable({
'dom': 'Bfrtip',
'data': [],
'serverSide': false,
'processing': false,
'scrollY': '50vh',
'scrollCollapse': true,
'searching': false,
'info': false,
'paging': false,
//'language': { "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Italian.json" },
'destroy': true,
'responsive': true,
'order': [],
'buttons': [
{
text: '<i class="fa fa-print" aria-hidden="true"></i>',
titleAttr: 'Stampa',
action: function (e, dt, node, config) {
return printDetails(e, dt, node, config);
}
},
{
extend: 'copyHtml5',
text: '<i class="fa fa-files-o"></i>',
titleAttr: 'Copia',
exportOptions: { columns: ':visible' }
},
{
extend: 'excelHtml5',
text: '<i class="fa fa-file-excel-o"></i>',
titleAttr: 'Excel',
exportOptions: { columns: ':visible' }
},
{
extend: 'pdfHtml5',
text: '<i class="fa fa-file-pdf-o"></i>',
titleAttr: 'PDF',
exportOptions: { columns: ':visible' }
},
{
text: '<i class="fa fa-exchange aria-hidden="true"></i>',
titleAttr: 'Cambio Giro',
action: function (e, dt, node, config) {
return cambioGiro(e, dt, node, config);
}
},
{
text: '<i class="fa fa-bars aria-hidden="true"></i>',
titleAttr: 'Cambio Sequenza',
action: function (e, dt, node, config) {
return cambioSequenza(e, dt, node, config);
}
},
{
text: '<i class="fa fa-upload aria-hidden="true"></i>',
titleAttr: 'Assegna giro',
action: function (e, dt, node, config) {
return AssegnaGiro(e, dt, node, config);
}
},
],
'columns': [
{ data: "name", title: "Seq.", className: "dt-center details-control1", visible: true, orderable: true },
{ data: "position", title: "Cliente", className: "dt-center", visible: true, orderable: false },
],
'select': {
style: 'os',
selector: 'multi'
},
});
$.ajax({
type: "POST",
//data: { "StringSearch": _data },
url: "/ajax/objects.txt",
//contentType: "application/json; charset=utf-8",
//dataType: "jsonp",
}).done(function (result) {
$(detailsTableOpt).DataTable().clear().draw();
$(detailsTableOpt).DataTable().rows.add($.parseJSON(result).data).draw();
var inputCheckBox = document.createElement('input');
inputCheckBox.id = "detail-select-all";
inputCheckBox.type = "checkbox";
inputCheckBox.onclick = function () { return selezionaTutto(this, $(detailsTableOpt).attr('id')); }
$($(detailsTableOpt).DataTable().table().header()).find('th').eq(0).append(inputCheckBox);
//setEditButton();
$('.wrapper').removeClass('loading');
$('#loadDetail' + rowData.CdGiro).hide();
}).fail(function (jqXHR, textStatus, errorThrown) {
alert("errore:" + textStatus);
});
// Add to the 'open' array
if (idx === -1) {
detailRows.push(row.index());
}
}
function selezionaTutto(t, d) {
var rows = $('#' + d).DataTable().table().rows({ 'search': 'applied' }).nodes();
$('input[type="checkbox"]:enabled', rows).prop('checked', $(t).is(":checked"));
}
// Add event listener for opening and closing second level child details
$('.child_table tbody').off().on('click', 'td.details-control1', function () {
var tr = $(this).closest('tr');
var row = $($(this).closest('table')).DataTable().row(tr)
var rowData = row.data();
ordineSearch = {}
ordineSearch["pAnnoOrd"] = rowData.AnnoOrdine;
ordineSearch["pNrOrd"] = rowData.NrOrdine;
var jsonR = LZString.compressToEncodedURIComponent(JSON.stringify(ordineSearch));
$('#loadPianoDiCarico').show;
$.get("/Home/OrdineModalJson?JsonData=" + jsonR, function (t) {
$('#modalOrdine').html(t);
$('#modalOrdine').modal({ keyboard: true, });
$('#modalOrdine').data('bs.modal').handleUpdate();
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log("OrdineModalJson err :" + textStatus);
$.toast('error', "L'operazione ha generato un errore.</br> Se l'errore persiste contattare l\'amministratore.</br></br></b>");
}).always(function () {
$('#loader-wrapper').hide();
$('#loadPianoDiCarico').hide();
});
});
}
$(document).ready( function () {
$('#tablePianodicaricoMaster').dataTable({
dom: 'frtip',
ajax: "/ajax/objects.txt",
paging: true,
pageLength: 10,
"filter": true,"info": false,"ordering": true,"processing": true,"retrieve": true, order: [[1, 'asc']],
responsive: true,
//language: {
// "url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Italian.json"
//},
columns: [
{
"data": null,
"defaultContent": '',
"title": "",
"className": "details-control",
"orderable": false,
"visible": true,
},
{
"data": "name",
"type": "text",
"title": "Giro",
"className": "dt-left",
"orderable": true,
"visible": true,
},
{
"data": "position",
"type": "text",
"title": "Ds. Giro",
"className": "dt-left progress style='background-color: transparent !important;'",
"orderable": true,
"visible": true,
},
{
"data": "office",
"type": "text",
"title": "Nr. Scarichi",
"className": "dt-right",
"orderable": true,
"visible": true,
},
],
select: true,
preDrawCallback: function (oSettings) {
$(this).find('tbody').hide();
return true;
},
drawCallback: function (oSettings) {
$(this).find('tbody').show("fast", function () {
$('#loadPianodicarico').hide();
$('#loader-wrapper').hide();
});
$('#tablePianodicaricoMaster').dataTable().resize();
},
});
$('#tablePianodicaricoMaster'+'_wrapper').addClass('actions');
$('#tablePianodicaricoMaster').on('page.dt', function () {
$('#tablePianodicaricoMaster').DataTable().rows().eq(0).each(function (idx) {
var row = $('#tablePianodicaricoMaster').DataTable().row(idx);
if (row.child.isShown()) {
row.child.hide();
}
});
})
$('#tablePianodicaricoMaster tbody').on('click', 'td.details-control', function () {
console.log('DataTable > click td.details-control [' + new Date() + "]");
onRowDetailsClick.call(this, $('#tablePianodicaricoMaster').DataTable());
});
$('#tablePianodicaricoMaster').on('draw.dt', function (e, settings) {
console.log('DataTable > draw.dt [' + new Date() + "]");
//console.trace();
console.log('Table ID: ', settings.nTable.id);
lastPage = $('#tablePianodicaricoMaster').DataTable().page();
var table = $('#tablePianodicaricoMaster').DataTable();
table.rows({ page: 'current' }).every(function () {
var row = this;
if (row.child.isShown()) {
var tr = $(table).closest('tr');
tr.removeClass('details');
row.child.hide();
// Remove from the 'open' array
detailRows.splice(row.index, 1);
}
});
});
} );
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. |