jQuery JQuery数据表如何使用OR逻辑在单列中搜索多个值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25812500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQuery datatable how to do search multiple value within single column using OR logic
提问by sh977218
for example, there is a column index of 7 about Source. I want to filter out all Source from A or B to be my result by typing A,B in the search input box. the format A,B is flexible, it can be A|B, A B.
例如,关于 Source 的列索引为 7。我想通过在搜索输入框中键入 A、B 来过滤掉 A 或 B 中的所有 Source 作为我的结果。A,B格式灵活,可以是A|B,A B。
Thanks for any help.
谢谢你的帮助。
采纳答案by zchpit
Use regexp: https://datatables.net/forums/discussion/6946/multiple-filters-on-same-column
使用正则表达式:https: //datatables.net/forums/discussion/6946/multiple-filters-on-same-column
Go to: http://www.datatables.net/release-datatables/examples/api/regex.html
转到:http: //www.datatables.net/release-datatables/examples/api/regex.html
- In column: Column - Office
- Put: tokyo|london
- And check: Treat as regex
- 在列中:列 - 办公室
- 输入:东京|伦敦
- 并检查:视为正则表达式
回答by Love Kumar
100% WorkingMultiple value search single column
100% 工作多值搜索单列
var oTable = $('#intrestTable1').DataTable( {});
oTable.column(5).search("caod|bullet",true,false).draw();