我正在使用datatables中的fnFilter函数,在尝试过滤“inv”时,所有以“inv”开头的内容都被过滤掉了,包括“invc”和“invk”。如何解决这个问题并只获取精确匹配的结果?
代码:
$("#user-lock-status-filter select").change(function() {
oUserTable.fnFilter($(this).val(), 12);
});
我正在使用datatables中的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);
//disabling smart search/regex and apply your own search
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)
ouserTable
是什么?我认为它是一个datatable变量。但是我已经使用了$('.dataTable').dataTable();
来创建一个jquery datatable。 - Avinash Raj
fnFilter
是做什么用的? - Johan