I working with datatables, and i try to make filtering possibility, and problem is that i want to chosse from checkboxes which column i need to filter.
So in case if i chosse one column i result i got 4 or 5 column, but i chosse 1, and i can find where the issues. [![enter image description here][1]][1]
As u can see on the image, i chose only one Stantion code but i got 5 columns for filtering, but i must have only one.
My code: [jsfinddle][2]
addSpliting('');
function addSpliting(val) {
if(val != '') {
$("#test1").DataTable({
destroy: true,
searchPanes: {
layout: 'columns-4',
},
dom: 'Pfrtip',
columnDefs: [{
searchPanes: {
show: true,
},
targets: val
}]
});
}
else {
$("#test1").DataTable({
destroy: true
});
}
}
function setFilters() {
$("table thead tr th").each(function(index) {
var boxes = `<label>
<input type="checkbox" class="checkbox" id="${index}"/>
${$(this).text()}
</label>`
if ($(this).text() != "") $(".checkBoxes").append(boxes);
});
}
setFilters();
$("#createFilter").on("click", function() {
var columFilters = [];
$('.checkbox:checked').each(function () {
columFilters.push(parseInt($(this).attr('id')));
});
addSpliting(columFilters);
});