JavaScript
$(document).ready(function() {
function cbDropdown(column) {
return $('<ul>', {
'class': 'cb-dropdown'
}).appendTo($('<div>', {
'class': 'cb-dropdown-wrap'
}).appendTo(column));
}
var table = $('#example').DataTable({
orderCellsTop: true,
fixedHeader: true,
});
$('#example thead tr').clone(true).appendTo('#example thead');
$('#example thead tr:eq(1) th').each(function(i) {
if (i <= 7) {
$(this).html('<input type="text" placeholder="Search ' + title + '" />');
var title = $(this).text();
$(this).html('<input type="text" placeholder="Search ' + title + '" />');
$('input', this).on('keyup change', function() {
if (table.column(i).search() !== this.value) {
table
.column(i)
.search(this.value)
.draw();
}
});
} else if (i == 8) {
var states = ["AK", "AL", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"];
var arrayLength = states.length;
var htmlcontent = '<div class="dropdown"><button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select State(s)</button><form class="dropdown-menu" style="overflow:scroll; height:200px;" aria-labelledby="dropdownMenuButton"><label class="dropdown-item">';
var title = $(this).text();
for (var i = 0; i < arrayLength; i++) {
htmlcontent += '<label class="dropdown-item"><input type="checkbox" name="' + states[i] + '" value="' + states[i] + '">' +...