Filter Column Data Based On Checkbox Value

Filter Column Data Based On Checkbox Value

SoVaSoVa Posts: 1Questions: 1Answers: 0

I'm trying to filter the data in the table based on the value of a checkbox in the DOM. If the checkbox is checked, I want all the data to be shown, and if not, only the rows with the value of "Yes" in their 6th column will be displayed. I have this function for filtering:

$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
if ($("#filteractive").prop("checked",true))
{
return true;
} else
{
if (data[5] == "Yes")
{
return true;
}
return false;
}
}
);

and

$(document).ready(function() {
$("#filteractive").on("change",function()
{
$("#sosticketlist").DataTable().draw();
}
);
});

to trigger the event. However, when I click on the checkbox, it always stays checked on (doesn't happen if I replace $("#sosticketlist").DataTable().draw(); with something else), and nothing happens to the table.

How should I make the checkbox work as expected?

This discussion has been closed.