<html>
<head>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.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 id="main-table" class="display " width="100%">
<thead>
<tr>
<th>
Business Unit
</th>
<th>
Project Name
</th>
<th>
Status
</th>
<th>
Phase
</th>
<th>
Completion Date
</th>
<th>
IT Capabilities
</th>
<th>
Business Sponsor
</th>
<th>
# of Risks
</th>
<th>
Capex
</th>
<th>
Proj Lead
</th>
<th>
Last Update
</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td colspan="11" style="font-weight: bold;">
Corp Project
</td>
<td>
<a href="#">Mativ Domain Migration 2023</a>
</td>
<td>
<span class="badge badge-success">On Target </span>
</td>
<td style="">
Cancelled
</td>
<td style="">
10/20/2023
</td>
<td style="">
Deliver Data & Analytics , Standardize Infrastructure
</td>
<td>
Shebnem Harris
</td>
<td>
0
</td>
<td>
No
</td>
<td>
Raj Gangaram
</td>
<td>
12/13/2023
</td>
</tr>
<tr class="even">
<td colspan="11" style="font-weight: bold;">
Corp Project
</td>
<td style="width: 15%;" class="dtr-control" tabindex="0">
<a href="#">Support Improvement Plan 2023</a>
</td>
<td>
<span class="badge badge-success">On Target </span>
</td>
<td style="">
Cancelled
</td>
<td style="">
10/20/2023
</td>
<td style="">
Deliver Data & Analytics , Standardize Infrastructure
</td>
<td>
Shebnem Harris
</td>
<td>
0
</td>
<td>
No
</td>
<td>
Raj Gangaram
</td>
<td>
12/13/2023
</td>
</tr>
<tr class="even">
<td colspan="11" style="font-weight: bold;">
Corp Project
</td>
<td style="width: 15%;" class="dtr-control" tabindex="0">
<a href="#">Network and Infrastructure Hardware Refresh 2023</a>
</td>
<td>
<span class="badge badge-success">On Target </span>
</td>
<td style="">
Cancelled
</td>
<td style="">
10/20/2023
</td>
<td style="">
Deliver Data & Analytics , Standardize Infrastructure
</td>
<td>
Shebnem Harris
</td>
<td>
0
</td>
<td>
No
</td>
<td>
Raj Gangaram
</td>
<td>
12/13/2023
</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;
}
thead input {
width: 100%;
}
var groupColumn = 0;
$(document).ready(function () {
// Setup clone - header filter
$('#main-table thead tr')
.clone(true)
.addClass('filters')
.appendTo('#main-table thead');
//Generate filter inputs and apply filter.
var table = $('#main-table').DataTable({
columnDefs: [{ visible: false, targets: groupColumn }, { width: '10%', targets: 5 }],
destroy: true,
orderCellsTop: true,
fixedHeader: true,
pageLength: 50,
dom: 'Bfrtip',
buttons: {
dom: {
button: {
className: 'dt-button button-page-length btn btn-secondary'
}
},
buttons: [
{
extend: 'excelHtml5',
className: 'btn btn-secondary',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
},
title: "",
filename: "All Projects List"
},
'pageLength'
]
},
"order": [[groupColumn, "asc"]],
"oLanguage": {
"sEmptyTable": "No data available."
},
"drawCallback": function (settings) {
var api = this.api();
var rows = api.rows({
page: 'current'
}).nodes();
var last = null;
api.column(groupColumn, {
page: 'current'
}).data().each(function (group, i) {
if (last !== group) {
$(rows).eq(i).before(
'<tr class="group"><td colspan="11" style="font-weight: bold;">' + group + '</td></tr>'
);
last = group;
}
});
},
initComplete: function () {
var api = this.api();
// For each column
api
.columns()
.eq(0)
.each(function (colIdx) {
// Set the header cell to contain the input element
var cell = $('.filters th').eq(
$(api.column(colIdx).header()).index()
);
var title = $(cell).text();
if ($(api.column(colIdx).header()).index() >= 0) {
if ($(api.column(colIdx).header()).index() == 3) {
$(cell).html('<input type="text" id="ReqDateRead" class="form-control datepicker" placeholder="MM/dd/yyyy" />');
}
else if ($(api.column(colIdx).header()).index() == 7) {
$(cell).html('<input type="checkbox" class="form-check-input filterCheckbox" name="capex" />');
}
else if ($(api.column(colIdx).header()).index() == 9) {
$(cell).html('<input type="text" id="lastUpdateDate" class="form-control datepicker" placeholder="MM/dd/yyyy" />');
}
else {
$(cell).html('<input type="text" class="form-control" style="width:100%" placeholder="Search" />');
}
}
// On every keypress in this input
$(
'input',
$('.filters th').eq($(api.column(colIdx).header()).index())
)
.off('keyup change')
.on('change', function (e) {
// Get the search value
$(this).attr('title', $(this).val());
var regexr = '({search})'; //$(this).parents('th').find('select').val();
var cursorPosition = this.selectionStart;
// Search the column for that value
api
.column(colIdx)
.search(
this.value != ''
? regexr.replace('{search}', '(((' + this.value + ')))')
: '',
this.value != '',
this.value == ''
)
.draw();
})
.on('keyup', function (e) {
e.stopPropagation();
$(this).trigger('change');
$(this)
.focus()[0];
//.setSelectionRange(cursorPosition, cursorPosition);
});
});
},
});
var dateRangeStart, dateRangeEnd;
$("#main-table_filter").prepend('<div class="filter-date-range-picker"><input class="form-control form-control-sm" id="date_range" type="text" placeholder="Select dates" style="width: 230px; margin-right: 10px;"></div>');
$("#date_range").daterangepicker({
autoUpdateInput: false,
locale: {
"format": "MM/DD/YYYY",
"cancelLabel": "Clear",
}
});
$("#date_range").on('apply.daterangepicker', function (ev, picker) {
dateRangeStart = moment(picker.startDate.format('MM/DD/YYYY'), 'MM/DD/YYYY');
dateRangeEnd = moment(picker.endDate.format('MM/DD/YYYY'), 'MM/DD/YYYY');
$(this).val(dateRangeStart.format('MM/DD/YYYY') + ' to ' + dateRangeEnd.format('MM/DD/YYYY'));
$.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
let min = dateRangeStart;
let max = dateRangeEnd;
let date = new Date(data[3]);
if (
(min === null && max === null) ||
(min === null && date <= max) ||
(min <= date && max === null) ||
(min <= date && date <= max)
) {
return true;
}
return false;
});
table.draw();
});
$("#date_range").on('cancel.daterangepicker', function (ev, picker) {
dateRangeStart = dateRangeEnd = null;
$(this).val('');
table.draw();
});
$('#range').on('change', table.draw);
$('#range').change();
table.buttons().container()
.appendTo('#datatable-buttons_wrapper .col-md-6:eq(0)');
$(".dataTables_length select").addClass('form-select form-select-sm');
//Set datepicker
$(".datepicker").datepicker({
format: 'MM/dd/yyyy'
});
//Open calander when click on icon.
$('.date-icon').on('click', function () {
$('.datepicker').focus();
});
$('input:checkbox[name="capex"]').on('change', function () {
//build a regex filter string with an or(|) condition
var checked = $('input:checkbox[name="capex"]').is(':checked');
if (checked) {
checked = "Yes"
} else {
checked = ""
}
table.column(8).search(checked).draw(false);
});
// Order by the grouping
$('#main-table tbody').on('click', 'tr.group', function () {
var currentOrder = table.order()[0];
if (currentOrder[0] === groupColumn && currentOrder[1] === 'asc') {
table.order([groupColumn, 'desc']).draw();
}
else {
table.order([groupColumn, 'asc']).draw();
}
});
});
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. |