Offer both smart and regex search on the same table?

Offer both smart and regex search on the same table?

lzamoralzamora Posts: 3Questions: 0Answers: 0
edited January 2011 in General
Hello,
The oSearch option is very popular with my customers!

I know oSearch allows users to enter either a regex or a simple string.

Is it possible for a single table to have two search boxes, one for regex search and another for simple string search?

I would simply use the regex search since it would find strings, too, but many strings in my table contain regex special characters (such as a dollar sign).

Many of my users do not know regexes and would be tripped up when searching for these special characters. But some of my users have asked for the regex option. I'd like to please all the people all the time. :-)

Thanks for your advice.
-Luis

Replies

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    Hi Luis,

    It certainly is possible (although only one filter is applied at a time - if you want to overrule that, a custom plug-in filter would be needed, or a clever combination of the static and regex inputs into a single regex). The way to acehive what you want with two inputs is simply to have different event handlers on them which call fnFilter with the needed parameter for the regex options. Something a little bit like this: http://datatables.net/examples/api/regex.html .

    Allan
This discussion has been closed.