Does anyone have examples on how to create a Datatablest filter checkbox? I want to display only rows that have a value above X or below Y being controlled by a checkbox.
You would have to write your own custom filtering function but after that the code would be vary simple
$(document).ready(function() {
$.fn.dataTableExt.afnFiltering.push(function(oSettings, aData, iDataIndex) {
var checked = $('#checkbox').is(':checked');
if (checked && aData[4] > 1.5) {
return true;
}
if (!checked && aData[4] <= 1.5) {
return true;
}
return false;
});
var oTable = $('#example').dataTable();
$('#checkbox').on("click", function(e) {
oTable.fnDraw();
});
});
fiddle http://jsfiddle.net/nicolapeluchetti/WVYNX/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With