使用预设和选择 table 值过滤 bootstrap table 中的记录

Filter records in bootstrap table with preset and selectable value

我有一个普通的 bootstrap table。由于某些原因,我只需要一个具有预设值的字段的过滤器,因此当显示 table 时,必须过滤记录。而且,此值必须 select 可以来自某些列表(例如常规 html select)。并且必须仅通过选择值来过滤记录,而不是通过单击某些提交按钮。

我已经在追求这个filter extension,但找不到如何使用它来满足我的所有要求。我将不胜感激任何帮助。当然,最好的方法是用例子来展示它。

假设您有一个 select 下拉菜单,id 为 "filter" 和一个 html table id 为 "records",您可以让此代码仅显示table 行在下拉列表中包含 selected 值。

$("#filter").change(function(){
    $("#records > tr").hide();
    $("#records > tr > td:contains('"+$(this).val()+"')").parent("tr").show();
});