https ://datatables.net/plug-ins/filtering/row-based/range_dates
Код: Выделить всё
$(document).ready(function() {
$(function() {
$("#datepickerStart").datepicker();
$("#datepickerEnd").datepicker();
});
// Setup - add a text input to each footer cell
$('#example tfoot th').each(function() {
var title = $(this).text();
if (title === "Start date") {
$(this).html('');
} else if (title === "End date") {
$(this).html('');
} else {
$(this).html('');
}
});
// DataTable
var table = $('#example').DataTable({
});
$('#example tbody').on('click', 'tr', function() {
$(this).toggleClass('selected');
});
$('#example tbody')
.on('mouseenter', 'td', function() {
var colIdx = table.cell(this).index().column;
$(table.cells().nodes()).removeClass('highlight');
$(table.column(colIdx).nodes()).addClass('highlight');
});
$('#button').click(function() {
alert(table.rows('.selected').data().length + ' row(s) selected');
});
// Apply the search
table.columns().every(function() {
var that = this;
$('input', this.footer()).on('keyup change', function() {
if (that.search() !== this.value) {
that
.search(this.value)
.draw();
}
});
});
});
Код: Выделить всё
tfoot input {
width: 100%;
padding: 3px;
box-sizing: border-box;
}
tr.highlight {
background-color: blue !important;
}
Код: Выделить всё
Name
Position
Office
Age
Start date
End date
Salary
Name
Position
Office
Age
Start date
End date
Salary
Tiger Nixon
System Architect
Edinburgh
61
2011/04/25
2011/04/27
$320,800
Garrett Winters
Accountant
Tokyo
63
2011/07/25
2011/04/29
$170,750
Ashton Cox
Junior Technical Author
San Francisco
66
2009/01/12
2011/04/28
$86,000
Cedric Kelly
Senior Javascript Developer
Edinburgh
22
2012/03/29
2012/03/30
$433,060
Airi Satou
Accountant
Tokyo
33
2008/11/28
2008/11/30
$162,700
Brielle Williamson
Integration Specialist
New York
61
2012/12/02
2012/12/21
$372,000
Подробнее здесь: https://stackoverflow.com/questions/420 ... nge-filter