filtering using "natural" wildcard * ?

filtering using "natural" wildcard * ?

trucmuche2005trucmuche2005 Posts: 71Questions: 22Answers: 2

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

  • allanallan Posts: 61,705Questions: 1Answers: 10,102 Site admin

    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

  • trucmuche2005trucmuche2005 Posts: 71Questions: 22Answers: 2

    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 ?

  • allanallan Posts: 61,705Questions: 1Answers: 10,102 Site admin

    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

  • trucmuche2005trucmuche2005 Posts: 71Questions: 22Answers: 2

    Oh sorry. I have to sleep :smiley: "Javascript/Jquery" of course...

  • allanallan Posts: 61,705Questions: 1Answers: 10,102 Site admin

    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

  • trucmuche2005trucmuche2005 Posts: 71Questions: 22Answers: 2

    Done ! Thank you ! :-)

This discussion has been closed.