I have added the range_filter plugin to my DataTable
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = parseInt( $('#min').val(), 10 );
var max = parseInt( $('#max').val(), 10 );
var ooh = parseInt( data[7] ) || 0; // use data for the ooh column
if ( ( isNaN( min ) && isNaN( max ) ) ||
( isNaN( min ) && ooh <= max ) ||
( min <= ooh && isNaN( max ) ) ||
( min <= ooh && ooh <= max ) )
{
return true;
}
return false;
}
);
However, when I filter, I see this in the console:
Uncaught TypeError: Reduce of empty array with no initial value
How do I address this issue?
Update: Console is finding an error in my summation code where ".reduce" is when i place a value inside the "min" "max" filters
// Total DEC over current page
if (api.column( 6 ).data().length){
var decTotal = api
.column( 6, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
} ) }
else{ decTotal = 0};