<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.19/js/dataTables.jqueryui.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/responsive.jqueryui.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/dataTables.jqueryui.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.jqueryui.min.css"/>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<meta charset=utf-8 />
<title>DataTables - JS Bin</title>
</head>
<body>
<div class="container">
<button>Column search</button>
<!-- DL COURSES -->
<div class="sec-title">Distributed Learning Courses</div>
<div id="indvTableFilters" class="filters">
<div class="flexGrid_justifySpaceBetween"><label id="indvTrngFltr-2" class="filterInput">Training Type:<br /></label> <label id="indvTrngFltr-3" class="filterInput">Course Type:<br /></label> <label class="filterInput">Key word search:<br /><input id="global_filterCourses" class="global_filterCourses" type="text" /></label></div>
</div>
<table id="coursesTable" class="display" style="width: 100%;">
<thead>
<tr>
<th>Course Title</th>
<th>Target Audience</th>
<th>Training Type</th>
<th>Course Type</th>
<th>ATRRS School Code</th>
<th>Course Length (Hrs)</th>
<th>Enrollment Instructions</th>
<th>Course Scope</th>
<th>Special Information</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Course Title</th>
<th>Target Audience</th>
<th>Training Type</th>
<th>Course Type</th>
<th>ATRRS School Code</th>
<th>Course Length (Hrs)</th>
<th>Enrollment Instructions</th>
<th>Course Scope</th>
<th>Special Information</th>
</tr>
</tfoot>
</table>
</div>
</div>
<!-- COLLECTIVE TRAINING --> </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 () {
//ACCORDION CLICK
var elements = document.getElementsByClassName("usa-accordion__button");
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener("click", toggleAccordion, false);
}
function toggleAccordion() {
var elements = document.getElementsByClassName("usa-accordion__content");
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute("hidden","");
}
var expanded = this.getAttribute("aria-expanded");
if (expanded == "false") {
this.scrollIntoView({behavior: "smooth" , block: "start", inline: "nearest"});
}
}
//Init the individual training datatable
$("#coursesTable").DataTable({
responsive: true,
"ajax": "/ajax/objects.txt",
"columns": [
{ "data": "name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "extn" },
{ "data": "start_date" },
{ "data": "salary" },
{ "data": "extn" },
{ "data": "start_date" },
{ "data": "salary" }
],
columnDefs: [
{"className": "tblcellNoWrap", "targets": 0},
{"className": "none", "targets": [1,4,5,6,7,8]},
//{"searchable": false, "targets": [2,3,4,5,6,7]},
{"responsivePriority": 1, "targets": 0}
],
order: [[1, "asc"]],
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
initComplete: function () {
//Populate the select input field with unique occurences of column data
this.api().columns([2,3]).every( function () {
var column = this;
var select = $("<select id=`selIndvTrngFltr-" + column.index() + "`><option value=>Select All</option></select>")
.appendTo( $("#indvTrngFltr-" + column.index()) )
//.appendTo( $(column.footer()).empty() )
.on( "change", function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
var colid = this.parentElement.id.split("-")[1];
if( colid == 1) {
column
.search( this.value )
.draw();
var searchTermJob = this.value;
$(".linkJobSearch").attr("href", function(i, val) {return val.substr(0, val.lastIndexOf("=") + 1) + searchTermJob;});
}
else {
column
.search( val ? "^" + val + "$" : "", true, false )
.draw();
}
});
column.data().unique().sort().each( function ( val, j ) {
var dispVal = "";
//If the value has an `;`, it is from the Target Audience column and needs to be split
if(val.indexOf(";") > 0) {
//Split on the semicolon to get all of the items
var arrItems = val.split(";");
for (var i = 0;i < arrItems.length - 1;i++) {
if(arrItems[i]) {
dispVal = arrItems[i];
if(arrTrgtAud) {
var a = arrTrgtAud.indexOf(dispVal);
if(a == -1) {
select.append("<option value=" + dispVal + ">" + dispVal + "</option>");
arrTrgtAud[j] = dispVal;
j = j++;
}
} else {
select.append("<option value=" + dispVal + ">" + dispVal + "</option>");
arrTrgtAud[j] = dispVal;
j = j++;
}
}
}
} else {
if(val.indexOf("<") == 0){
val = val.substring(val.indexOf(">") + 1, val.lastIndexOf("<"));
}
if(val.length > 30){
dispVal = val.substring(0,30) + "...";
} else {
dispVal = val;
}
if(dispVal) {
select.append("<option value=" + val + ">" + dispVal + "</option>");
}
}
});
});
}
});
$('button').on('click', function () {
$("#coursesTable").DataTable().column(2).search('Tokyo').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. |