Pull back a row if it contains a match
Pull back a row if it contains a match
KeiSenpai
Posts: 21Questions: 8Answers: 0
Hello All,
I implemented a checkbox to filter a table that pulls back any time records of XX:X1.
I am using:
if ($(this).prop('checked')) {
var spRegex = '^[0-9]{1,2}:[0-9][1]$'
tableAll.columns([9,10]).search(spRegex).draw();
} else {
tableAll.columns([9,10]).search('', false, false).draw();
}
The columns actually span from 4-17, but it only works if I specify one column. I am assuming it is because there may or may not be a match in column 4-9, but there is one in 10. Is the approach above correct or will I need to seek alternative route?
Answers
Datatables basically does and AND search across all the columns. Sounds like you want an OR search. You can create a Search plugin to perform an OR search. See if this
thread helps get you started.
Kevin
Hey @kthorngren
I appreciate the answer, and sorry for the delayed response.
I will try to dig for some more examples using the search plugin.
This does seem to be the way to go. This is what I have in my checked event for the checkbox:
Obviously that works for one column, but I have columns 4-17 that would need to be in the OR selection. So the check event would need to kick off the draw() function?
Looking to show all 'locations' that are one off, XX:X1.