Column search by conditional integer range
Column search by conditional integer range
rdm
Posts: 194Questions: 55Answers: 4
Here is a simple question about the table.column(x).search(y) function. How do you filter by a range of integers?
For example:
// if age.val() == "Yes" then search 18 or above.
// if age.val() == "No" then search 17 or below
// if age.val() == "" then no filter
t.column(5).search(/* search integer range depending on age.val() */);
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Maybe the Range Search example will help get you started.
Kevin
@kthorngren -- I independently found that page but I'm having difficulty getting the
$.fn.dataTable.ext.search.push
function to trigger onage.change()
Maybe you can post a test case with what you have and someone can help troubleshoot.
Kevin
Here is what is meant to trigger the column filter:
And this is the function inspired from here.
I added the console.log statement and see no evidence this function is triggered -- either in the console screen or in the resulting table. The example function is based on a min/max model, whereas mine is based on a greater or less than criterion value, which explains the if logic.
The problem is that this function does not trigger at all.
Disregard. It all stemmed from the lack of a hash sign in an earlier variable declaration.
Now that I put in the missing hash sign, the function triggers and works as intended.
Thanks for posting back - great to hear you've got it working now.
Allan