How to get exact match with fnFilter?

I use fnFilter in datatables and when I try to filter "inv" everything else starting with "inv" is also filtered. that is, "invc", "invk" are also displayed in the filtering results. How to solve this problem and get only exact matches?

code:

$("#user-lock-status-filter select").change(function() { oUserTable.fnFilter($(this).val(), 12); }); 
+6
source share
1 answer

Change it

 oUserTable.fnFilter($(this).val(), 12); 

to

 oUserTable.fnFilter("^"+$(this).val()+"$", 12, false, false); //disabling smart search/regex and apply your own search 

Example

Doc

Params for fnFilter

 1.{string}: String to filter the table on 2.{int|null}: Column to limit filtering to 3.{bool} [default=false]: Treat as regular expression or not 4.{bool} [default=true]: Perform smart filtering or not 5.{bool} [default=true]: Show the input global filter in it input box(es) 6.{bool} [default=true]: Do case-insensitive matching (true) or not (false) 
+8
source

Source: https://habr.com/ru/post/955015/


All Articles