简体   繁体   中英

How to get exact match using fnFilter?

I'm using fnFilter in datatables and while trying to filter "inv" everything else starting with "inv" also get filtered. that is "invc", "invk" are also showing in filtered result. How to solve this and get the exact matches only?

code:

$("#user-lock-status-filter select").change(function() {
        oUserTable.fnFilter($(this).val(), 12);
    });

Change this

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's input box(es)
6.{bool} [default=true]: Do case-insensitive matching (true) or not (false)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM