I'm trying to use Bootstrap-Table to show my data and I want to filter rows that a specified cell is empty and I don't want them to show up.
$('#tableId').bootstrapTable('refreshOptions', {
filterOptions: {
filterAlgorithm: "not"
}
});
$('#@tableId').bootstrapTable('filterBy', {"specifiedCell":""});
Sadly filterAlgorithm does not support not
at code above.
What should I write in front of filterAlgorithm to use a custom filter?
I didn't see any good explanation about it in internet but by testing I understand that custom filter template is like this:
$('#tableId').bootstrapTable('refreshOptions', {
filterOptions: {
filterAlgorithm: function (row, filter) {
if(row['specifiedCell'] != filter['specifiedCell']){ //check row or row[cell] condition by `filter`
return true;//it will the `row` will display.
} else {
return false;//it wont show the `row`
}
}
}
});
$('#@ViewBag.dynamicData["tableId"]').bootstrapTable('filterBy', {
"specifiedCell":""
});
In the code above I checked specified cell in the row with filter that contains values that shouldn't be on the table so by returning true on not being in filter I made custom not
filter.