我在数据表中使用fnFilter,在尝试过滤“inv”时,以“inv”开头的其他内容也会被过滤掉。即“invc”,“invk”也显示在过滤结果中。如何解决这个问题并获得完全匹配?
代码:
$("#user-lock-status-filter select").change(function() {
oUserTable.fnFilter($(this).val(), 12);
});
答案 0 :(得分:10)
更改此
oUserTable.fnFilter($(this).val(), 12);
到
oUserTable.fnFilter("^"+$(this).val()+"$", 12, false, false);
//disabling smart search/regex and apply your own search
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)