Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datatables: include space in filter string

Tags:

datatables

I have an alphanumeric column with strings like "1, 2, 2". When I type "1, 2, 2" in the search, it seems to be returning all cells with "1," and "2,". What can I do so the search returns only "1, 2, 2"?

Using Datatables 1.9

like image 661
Adam Fratino Avatar asked Jan 04 '14 20:01

Adam Fratino


2 Answers

Turn smart filtering off, bRegex as true treats search string as regular expression:

"oSearch": { "bSmart": false, "bRegex": true }
like image 122
Adam Fratino Avatar answered Jan 03 '23 15:01

Adam Fratino


Sorry, I am not allowed to comment on the previous answer.

In the documetation Options (legacy documentation for DataTables v1.9) says: "As an object the "sSearch" parameter must be defined, but all other parameters are optional."

If you do not define it, you can eventually get the error "a.oPreviousSearch.sSearch is undefined".

Then add sSearch to bSmart and bRegex parameters:

        "oSearch": {
            "bSmart": false, 
            "bRegex": true,
            "sSearch": ""                
        }
like image 28
MrMojoRisin Avatar answered Jan 03 '23 13:01

MrMojoRisin