Scenario:
I need to filter out data from the datatable based on the selection that has been made from the user. To implement this I have a tree control which represents the hierarchy of the data in the datatable. When a user unchecks a certain node in the tree. That data should be taken out from the datatable.
Question:
I tried using the following filter function but it gives me the filtered data.
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
I would appreciate any help on this.
Thanks
答案 0 :(得分:0)
简单的答案是反转过滤器。即更改过滤器以返回false,其中当前返回true,反之亦然。
您也可以通过反转您要查找的正则表达式来搜索。
答案 1 :(得分:0)
您可以实现自己的自定义搜索功能:
var table = $('#myTable').DataTable();
$.fn.dataTable.ext.search.push(
function(oSettings, aData, iDataIndex) {
var match = true;
$(".checkbox:checked").each(function(index) {
var cb = $(this);
var id = $(this).attr('id');
if (aData.toString().toLowerCase().indexOf(id) >= 0) {
match = false;
} else {
match = true;
}
});
return match;
});

请参阅演示here。希望它有所帮助。