custom filter and the resulting search vs filter issue, is there a solution?
custom filter and the resulting search vs filter issue, is there a solution?
I have made a moment/date filter:
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
var result = true;
$(".date").each(function(){
var el = $(this);
if(el.find("input").val()){
var dateFilter = moment(el.find("input").val(),"D MMM YYYY");
var dateCell = moment(table.cell(iDataIndex, subheaderHeader(el.parent())).cache("filter"));
if(el.hasClass("before")){
result = dateCell.isSameOrBefore(dateFilter);
} else if (el.hasClass("after")){
result = dateCell.isSameOrAfter(dateFilter);
} else {
result = dateCell.isSame(dateFilter);
}
}
});
return result;
}
);
Which appears to work quite nicely, issue is I'd like to make use of the functionality that search gives in the background, by using the inputs value in column().search()
but doing so breaks the filter to only show those filtered that are also equal to the search value. Reasoning for wanting to use search being for state saving and a check over all columns to see whether they have anything in column().search()
.
Is the a means by which that I can input into the search... without it actual being applied? I've tried using columns.searchable
false, but this just prevents it from showing any rows at all. Is there any other options that i'm missing?
(Apologise about the custom function to get the subheaders header, but it's a fallout of another question I've asked. Could probably do it via a footer input if trying to replicate, but I don't like footers much It's also bootstraped so the input is within a div/span hence the .find("input"))