你应该使用这个函数:
function filterme() {
//build a regex filter string with an or(|) condition
var types = $('input:checkbox[name="type"]:checked').map(function() {
return '^' + this.value + '\$';
}).get().join('|');
//filter in column 0, with an regex, no smart filtering, no inputbox,not case sensitive
otable.fnFilter(types, 0, true, false, false, false);
//build a filter string with an or(|) condition
var frees = $('input:checkbox[name="free"]:checked').map(function() {
return this.value;
}).get().join('|');
//now filter in column 2, with no regex, no smart filtering, no inputbox,not case sensitive
otable.fnFilter(frees, 2, false, false, false, false);
}
看看 cmets 看看它做了什么。
像这样从你的 html 调用它:
<input onchange="filterme()" type="checkbox" name="free" value="0">0
<input onchange="filterme()" type="checkbox" name="free" value="1">1
Plunker 是 HTML 和 JS Snippets 的测试平台,它极大地帮助其他人了解您的问题所在,并快速响应如何解决问题。它就像 html/js/css 编辑器一样工作,每次按键都会呈现您的示例,非常棒。
Click here to see how I fixed your issue with Plunker
在 Plunker 的左侧,您会找到我在此过程中使用的文件(index.html 和 script.js)
虽然这可行并且应该让您知道如何继续,但您应该考虑使用单选按钮作为免费过滤器,因为这样更有意义。
由于这是一个安静而复杂的问题,如果需要更多解释,请与我联系。