本文介绍了如何使用 fnFilter 获得精确匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据表中使用 fnFilter 并且在尝试过滤inv"时,其他所有以inv"开头的内容也会被过滤.即invc"、invk"也显示在过滤结果中.如何解决这个问题并仅获得完全匹配?

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?

代码:

$("#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

示例

文档

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)

这篇关于如何使用 fnFilter 获得精确匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 05:32