Date filter outside datatable
Date filter outside datatable
I need to filter datatable based on date range, i tired using custom filter but the filter is applied only once, all the unmatched records get deleted from datatable.
here is my code :
oTable.dataTableExt.afnFiltering.push{
function( oSettings, aData, iDataIndex ) {
var fromDate = new Date($( "#applicationDateFrom" ).val());
var toDate = new Date($( "#applicationDateTo" ).val());
var cellDate = new Date(aData[4]);
cellDate.setDate(cellDate.getDate()+1);
//alert(cellDate);
if(cellDate < fromDate){
return false;
}else if(cellDate > toDate){
return false;
}else
return true;
})
}
Whats wrong in this code, how can i reset the custom filter ?
I tried using column filter plugin but that doesn't suit my requirements as I have the date pickers outside the datatables.
here is my code :
oTable.dataTableExt.afnFiltering.push{
function( oSettings, aData, iDataIndex ) {
var fromDate = new Date($( "#applicationDateFrom" ).val());
var toDate = new Date($( "#applicationDateTo" ).val());
var cellDate = new Date(aData[4]);
cellDate.setDate(cellDate.getDate()+1);
//alert(cellDate);
if(cellDate < fromDate){
return false;
}else if(cellDate > toDate){
return false;
}else
return true;
})
}
Whats wrong in this code, how can i reset the custom filter ?
I tried using column filter plugin but that doesn't suit my requirements as I have the date pickers outside the datatables.
This discussion has been closed.
Replies
You can refilter the table just by calling fnDraw .
Allan