filtering using "natural" wildcard * ?
filtering using "natural" wildcard * ?
Hello,
I would like to filter my table using the wildcard * like this :
- if I write 40* the table shows only the lines which BEGINS by 40
- if I write 20 the table shows only the lines which ENDS with 20
- if I write *20 the table shows only the lines which CONTAINS 20
I tried the table.columns(id_col).search(this.value, true).draw() function and I can filter using regexp, it works perfectly... But I would like to allow the "natural" use of the wildcard * as described above. Is that possible ?
Many thanks !!
T.
Answers
Currently no - sorry. That sounds like a good addition to the smart search though. You could probably do it with your own regex rather than using the built in smart filer.
Allan
Thank you. Is there a way to define my own custom regexp rules ? I'm thinking about redefine the * operator to do what I want... Is there a way in PHP ?
In PHP? DataTables is a Javascript library. Unless you are using server-side processing, in which case yes, this would be a PHP modification. There probably is a way to do that, but it is not something I've attempted before. If you are using an SQL database then you would use the
%
wildcard operator.Allan
Oh sorry. I have to sleep "Javascript/Jquery" of course...
The
column().search()
option provides a regex option. If you use that make sure you turn off the smart filter as well, otherwise weird things happen!Allan
Done ! Thank you ! :-)