jQuery数据表-搜索完全匹配 [英] JQuery DataTable - Search for exact match
问题描述
我查看了其他几个回复,并尝试了所有回复,但没有任何效果.我的桌子上有以下物品:
I have looked at several other responses and tried them all but nothing works. I have the following in my table:
Date Severity
2016-04-24 Not Critical
2016-04-24 Critical [what I need returned]
2017-01-09 Not Critical
2017-09-13 Critical
我正在尝试搜索2016年(年)的严重性为严重"(值)的所有行.到目前为止,我有:
I am trying to search for all rows where severity is Critical (value) for 2016 (year). So far I have:
table.search( year + " " + value ).draw();
这将返回2016年的两行.如何获取它只返回我需要的行?
This returns both rows for 2016. How can I get it to return just the row that I need?
推荐答案
您可能需要通过 search()
和 column().search()
API方法.
You may need to enable and use regular expressions with search()
and column().search()
API methods.
Since you need to search two columns simultaneously, it may be better to combine two calls to column().search()
.
例如:
table
.column(0).search('2016')
.column(1).search('^Critical$', true, false)
.draw();
其中0
和1
是日期和严重性列的索引.
where 0
and 1
are indexes of your date and severity columns.
有关代码和演示,请参见此示例.
See this example for code and demonstration.
这篇关于jQuery数据表-搜索完全匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!