Filter with multiple checkbox
Filter with multiple checkbox
Hello,
I would like to filter the data of my table (server-side), thanks to several checkboxes on a single column.
Currently, it works when only one checkbox is checked. When multiple checkboxes are checked, I have no more data
In my html file :
<input type="checkbox" name="statut" value='Clos'> Clos
<input type="checkbox" name="statut" value="Annulé"> Annulé
In my JS file :
$('input:checkbox').on('change', function () {
var stats = $('input:checkbox[name="statut"]:checked').map(function() {
return this.value;
}).get().join('|');
$('.data-table').DataTable().column(5).search(stats, true, false, false).draw(false);
});
To summarize, it works:
$('.data-table').DataTable().column(5).search("Clos", true, false, false).draw(false);
It does not work :
$('.data-table').DataTable().column(5).search("Clos|Annulé", true, false, false).draw(false);
This question has an accepted answers - jump to answer
Answers
Hi fbl,
I have tried to replicate the problem here. Seems to work fine for me. If this doesn't fix it for you, feel free to edit it to show your particular issue.
Hope this helps,
Sandy
Thank you for your answer, I do not understand why at home it does not work. I do not know how I could show you my code because it's a symfony project and I use several pages
Sorry for double post.
I feel that regex does not work
Maybe my js file can help you?
Since you are using server side processing your server script will need to support the regex search. Take a look at this thread and the threads it links to for more information.
Kevin