DataTables列搜索完全匹配 [英] DataTables column search for exact match

查看:159
本文介绍了DataTables列搜索完全匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用jQuery Datatables插件.我正在尝试搜索与列中的数据完全匹配的字符串.我检查了 jQuery DataTables-按完全匹配过滤列,这是行不通的就我而言我的搜索字符串是带|的正则表达式.可能看起来像Logged In|Active|Not Active的符号.当搜索字符串包含时,使用以下搜索时也会显示带有Not ActiveActive(Logged In|Active)记录:

I am using jQuery Datatables plugin in my application. I am trying to search for a string that exactly matches the data in a column. I checked jQuery DataTables - Filter column by exact match which is not working for my case. My search string is a regular expression with | symbols which might look like Logged In|Active|Not Active. When the search string contains, Active( Logged In|Active ) records with Not Active are also showing up when I use the following search:

jQuery("#myTable").DataTable()
                .columns("#status")
                .search("^"+status+"$",true,false)
                .draw();

感谢您的帮助.预先感谢!

Any help is appreciated. Thanks in advance!

推荐答案

jQuery("#myTable").DataTable()
                .columns("#status")
                .search("(^"+status+"$)",true,false)
                .draw();

这行得通!

这篇关于DataTables列搜索完全匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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