如何使用fnFilter获得完全匹配? [英] How to get exact match using fnFilter?

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

问题描述

我在数据表中使用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); 
//禁用智能搜索/正则表达式并应用自己的搜索

示例



Doc



fnFilter的参数

  1. {string}:过滤
上的表的字符串2. {int | null}:将过滤限制为
的列3. {bool } [default = false]:将正则表达式视为
4. {bool} [default = true]:执行智能过滤
5. {bool} [default = true]:显示输入全局过滤器的输入框
6. {bool} [default = true]:不区分大小写的匹配(true)或不(false)
/ pre>

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)

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆