How to filter a column for values less than X
How to filter a column for values less than X
wjmccormick
Posts: 10Questions: 2Answers: 0
I have a table with a column that has numeric values (+ and -). I would like to be able to filter on that column, where the values are less than a given number.
I am using the function below to handle the filter/search and have it working to show all ("") and 0 ("^0$"). I just cannot get the search to work where the value is less than X (e.g. find all values less than X). Any assistance would be greatly appreciated.
function FilterDaysDue(search) {
dtTable.column(7).search( search, true, false ).draw();
}
This discussion has been closed.
Answers
Hi @wjmccormick ,
My example on this thread may help. This is a custom search that returns hits between two values. Yours will be different, but this is a good example of how to create custom searches,
Cheers,
Colin
I finally got it.
Here are the strings that I pass to my FilterDaysDue function for the regex search parameter:
If the value is <= 0
^-|^[0]
If the value is > 0 and <= 10
^(0?[1-9]|1[0])$
If the value is > 10 and <= 30
^(0?1[1-9]|2[0-9]|3[0])$
If the value is > 30 and <= 45
^(0?3[1-9]|4[0-5])$