column search for date range with datatables
column search for date range with datatables
BlidaAlg
Posts: 9Questions: 4Answers: 0
hi,
i'm trying to make two input with min date and max date i try this code but nothing work and when the page begin the table starting with no data found... please help
require(['datatables', 'jquery'], function(datatable, $) {
$(document).ready(function() {
var table = $('#myTable').DataTable();
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = $('#date').val();
var max = $('#date_next').val();
var date = data[3];
if ( ( isNaN( min ) && isNaN( max ) ) ||
( isNaN( min ) && date <= max ) ||
( min <= date && isNaN( max ) ) ||
( min <= date && date <= max ) )
{
return true;
}
return false;
}
);
$('#date, #date_next').change( function() {
table.draw();
} );
} );
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There is a good example in this thread.
Kevin
thank you very much it works perfectly