我在数据表中使用fnFilter,同时尝试过滤“inv”时,以“inv”开头的其他所有内容也会被过滤。也就是“invc”,“invk”也在过滤结果中显示。如何解决这个问题并只获得完全匹配?

代码:

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

最佳答案

改变这个

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


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

Example

Doc
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)

关于jquery - 如何使用fnFilter获得完全匹配?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19114586/

10-12 15:45