Search using user defined function

Search using user defined function

bglinkermanbglinkerman Posts: 1Questions: 1Answers: 0
edited April 2016 in Free community support

I'm trying to do something that seems to be a mix of filtering and searching and not sure how exactly to approach it. I've seen various examples in the discussion boards but nothing that really maps to what I want.

So in my DataTable I have individual column searching enabled and one column contains IP ranges in CIDR notation (e.g. 10.88.110.42/22). What I would like to do is when a user enters an IP address into the column search input box, loop through each record and check to see if the given IP address is within the range of IPs for each row. Those rows that match will be shown, those that do not will be hidden. So for example, if we have the following 2 rows:

[IP Range]
192.168.1.0/24
10.88.110.0/22

and someone searches for:

10.88.110.25

the only row visible will be:

[IP Range]
10.88.110.0/22

With column.search(input.value).draw(); I can only pass in a string/regex. What I'd like to do is have a function I could pass in that if it returns true it is a match and is shown (e.g. column.search(isIPInRange(input.value) ). Obviously, I cannot do this with the .search() method but is there some other way I can achieve this by using the value from the column search input box?

I looked at the filter option but it seems that it makes a completely new instance of the table instead of working with the current instance.

Thanks in advance

This discussion has been closed.