Trying to implement a filter to hide rows based on their index
Trying to implement a filter to hide rows based on their index
I created this filter It compares the index of the row to the starttime and endtime variables.
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
alert("in");
if (iDataIndex < startTime + 1)
return false;
if (iDataIndex > endTime + 1)
return false;
return true;
}
);
var table = $('#example').DataTable({
"bAutoWidth":false,
"scrollX": true,
"scrollCollapse": true,
"scrollY": $(slotValueGrid).height()*0.75,
"searching": false,
"bLengthChange": false,
"bPaginate": false,
"bInfo": false
});
new $.fn.dataTable.FixedColumns(table, {
leftColumns: 1
});
});
function displayAdvertRight() {
var e = document.getElementById("startTimeDDL");
startTime =parseInt(e.options[e.selectedIndex].value,10);
e = document.getElementById("endTimeDDL")
endTime = parseInt(e.options[e.selectedIndex].value,10);
$("#example").dataTable().api().fnDraw();
}
I have tried all the following calls to get the function to filter but it won't work, I always get a response that
$(...).dataTable(...).api(...).fnDraw is not a function or something along those lines and I have looked at the section in the faq regarding the dataTable vs DataTable but it does not solve anything
$("#example").dataTable().api().fnDraw();
$("#example").dataTable().api().draw();
$("#example").DataTable().fnDraw();
$("#example").DataTable().draw();