Can the DataTables search functionality utilize boolean search (using AND, OR keywords etc.)?

Can the DataTables search functionality utilize boolean search (using AND, OR keywords etc.)?

dtdevdtdev Posts: 9Questions: 4Answers: 0
edited September 2022 in Free community support

Can the DataTables search functionality utilize boolean search (using AND, OR, etc. keywords and wildcard placeholders)?

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Yes! You can utilize regex searches. See the search() docs for the different search modes available. The same applies to column().search(). If this option doesn't meet your needs you can create a Search Plugin where you have full control of how the search works.

    Kevin

  • dtdevdtdev Posts: 9Questions: 4Answers: 0

    Thanks Kevin. I'm aware of the RegEx search mode, but it doesn't seem to actually perform a BOOLEAN search from the search field. For example, if in the search field I type "foo OR bar" it doesn't filter only rows that contain either "foo" or "bar".

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited September 2022

    Thats because OR is not a regex operator. The token for regex OR searching is |. You can experiment with this example. Either in the Global Search or the Office column search enable regex and disable smart search. Enter the search string tokyo|london to see the OR search work.

    If you wanted the user to type tokyo OR london you could replace the OR with | in the appropriate filter function to build a proper regex string.

    Kevin

Sign In or Register to comment.