Datatables Filter - Exact search and smart search
Datatables Filter - Exact search and smart search
want to persist with the smart search ( search as i type ) that datatables has. The problem is, one of my columns shows values like: person and personnel. So with million records, it is hard for me to dig down to "person" with the column just showing "personnel" when i type "person".
I do not want only exact match. That would make me type the whole name as in : "person-xyz-123" in some cases.
Is there a way for me to specify say "person" in quotes and tell datatables that i just want to do exact search when i type in quotes and still persist with my normal search ?
Answers
With millions of records, I am assuming you are using server-side processing? If so, in the filter function you could probably do something like:
And change it so when the search starts with a pipe, it will perform either a LIKE search without the wildcard (%) before and after the search term, or you can just make it
WHERE column = search
or whatever fits your needs. Then just remember to take the pipe out of the string in your query.I'm sure there are other ways, and possibly a better way; but that should work.
This is how i solved my problem. Below is the helper function i created: