如何使用fnFilter获得完全匹配? [英] How to get exact match using fnFilter?
本文介绍了如何使用fnFilter获得完全匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码:
$(#user-lock-status -filter select)。change(function(){
oUserTable.fnFilter($(this).val(),12);
});
解决方案
更改此
oUserTable.fnFilter($(this).val(),12);
至
oUserTable.fnFilter(^+ $(this).val()+$,12,false,false);
//禁用智能搜索/正则表达式并应用自己的搜索
fnFilter的参数
1. {string}:过滤
/ pre>
上的表的字符串2. {int | null}:将过滤限制为
的列3. {bool } [default = false]:将正则表达式视为
4. {bool} [default = true]:执行智能过滤
5. {bool} [default = true]:显示输入全局过滤器的输入框
6. {bool} [default = true]:不区分大小写的匹配(true)或不(false)
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
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屋!
查看全文