filtering datatable with checkboxes, column value 'S' appear value 'N' dont
filtering datatable with checkboxes, column value 'S' appear value 'N' dont
andrebertonha
Posts: 11Questions: 1Answers: 0
I´m trying this question that i founded here, but with no success
$(document).ready( function () {
var table = $('#dataTableClientes').DataTable();
$('input:checkbox').on('change', function () {
//build a regex filter string with an or(|) condition
var origens = $('input:checkbox[name="orig"]:checked').map(function() {
return '^' + this.value + '$';
}).get().join('|');
//filter in column 5, with an regex, no smart filtering, not case sensitive
table.column(5).search(origens, true, false, false).draw(false);
table.column(6).search(origens, true, false, false).draw(false);
table.column(7).search(origens, true, false, false).draw(false);
table.column(8).search(origens, true, false, false).draw(false);
});
} );
This discussion has been closed.
Answers
You posted a similar question in this thread:
https://datatables.net/forums/discussion/53671/how-can-i-use-multiple-checkbox-filter#latest
Its hard to say what the problem is without seeing the full picture of what you have. Please post a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
The example I posted in the other thread does work. I'm not sure why the same solution doesn't work for you without seeing it.
Kevin
It´s a combination of checkboxes and one select
When click just refresh datatable result with the selected value
I will post some picture, thanks
Its difficult to help with your code without actually seeing it in action. Can you post a link to your page or a test case replicating the issue?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
https://jsfiddle.net/w8oyfdub/1/
is not working, here i could filter by first checkbox
so the logic to filter the 4 checkboxes, i dont now if this is correct way yo do
thanks for helping
https://jsfiddle.net/9vxmcfLs/13/
Thanks for the test case. That will help us to get you going. You may need to use a Search Plugin for this depending on how you want it to behave.
I understand you have four columns which can have either
S
orN
values. If you checkSite
for example then you want to search theS
column forS
or if unchecked forN
. You have the same for the other 3 columns.Do you want this to be an
and
or anor
search?How do you want to reset the search to show the whole table? Meaning how do you want to show both
N
andS
in the Site column?Maybe you need two checkboxes for each column; one for
S
and one forN
.Let us know what you want to do then we can help you adjust your code. If you want two checkboxes for each column please adjust your test case and post the new link.
Kevin
I want to be an and search. If the 4 checkboxes are checked then will show only registers who have this match
When the user uncheck some of check boxes so I have to show the match result of others with S value
When uncheck all checkboxes the entire datatable must to be shown
André
https://jsfiddle.net/8h3ujegb/
Not sure if this is exactly what you want but it should get you started:
https://jsfiddle.net/tnvf2aLq/2/
It uses the search plugin. Inside the function its just a matter of Javascript code to determine if the row should be displayed (return true) or not displayed (return false). Hopefully you can workout any JS changes needed to reach your solution.
Kevin
Almost there, I´m trying to use .map function so when hidden 'S' value by other checkbox can be shown in users click
Not sure I understand what you want to do with the .map function but you will want it in the click event not the search plugin function since the plugin is called for each row.
Kevin
Thanks for helping Kevin so i reach the result that I want
not sure if ih the best solution but it´s working fine
so as soon as possible i will update one fiddle showing how it´s working
and get some feedback
Thanks for all
https://jsfiddle.net/andrebertonha/xk4hwvo7/30/
A feedback will be welcome