I created this filter to compare the index of the row to starttime and endtime variables. The idea is that the values of starttime and endtime correspond to the rows in the table.
$(document).ready(function () {
var startTime = 0;
var endTime = 23;
$.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();
I cant figure out how to get the filter event to fire since I can't seem to call draw()
});exrta beforefunction displayAdvertRight() {??