i'm using datatable with date range filter by using datepicker. When i set stateSave: true
it saves all values except the range set into the input datepicker field. Any help on this?
Have a look here: http://live.datatables.net/kajabeli/2/edit
DataTables has documented custom filters https://datatables.net/examples/plug-ins/range_filtering.html
That will filters age (similiar cases with yours)
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var start_date = Date.parse($('#start_date').val()) / 1000 || 0;
var end_date = Date.parse($('#end_date').val()) / 1000 || 0;
var value = Date.parse(data[5]) / 1000 || 0;
/* put your filter conditions here, */
if ( ( start_date && end_date ) ||
( start_date && value <= end_date ) ||
( start_date <= value && end_date ) ||
( start_date <= value && value <= end_date ) )
{
return true;
}
return false;
}
);
Add below codes after your dataTable initiation.
$('#start_date, #start_date').change( function() {
table.draw();
} );