bootstrap table: 过滤器控制不工作

bootstrap table: filter control not working

我的 bootstrap table 我想使用扩展 Filter Control

服务器端我用的是django。

我包括以下 css 和 js:

{% load bootstrap4 %}
{% bootstrap_css %}
{% bootstrap_javascript jquery='full' %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.1/bootstrap-table.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.1/extensions/filter-control/bootstrap-table-filter-control.min.css">

<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.1/bootstrap-table.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.1/extensions/filter-control/bootstrap-table-filter-control.min.js" ></script>

这是我的 html table:

<table
  id="table"
  data-toggle="table"
  data-pagination="true"
  data-pagination-h-align="left"
  data-pagination-detail-h-align="right"
  data-page-size="25"
  data-page-list="[10, 25, 50, 100, all]"
  data-search="true"
  data-show-columns="true"
  data-filter-control="true"
  data-show-search-clear-button="true"
  data-show-refresh="true"
  data-url="../get_track_list">
  <thead>
    <tr>
      <th data-field="datetime_start" data-formatter="DateFormatter" data-sortable="true" data-switchable="false" data-searchable="false">Date</th>
      <th data-field="name" data-formatter="ActivityLinkFormatter" data-switchable="false">Name</th>
      <th data-field="sport" data-formatter="SportSymbolFormatter" data-sortable="true" data-searchable="false" data-filter-control="select">Sport</th>
    </tr>
  </thead>
</table>

我的数据-url 是来自 django 请求的 json 文件。

结果 table 如下所示:

我在浏览器控制台中没有任何错误。我还看到创建了过滤器控件 div 但没有创建下拉字段?

我做错了什么,以至于没有创建 data-filter-control="select" 字段? table 是在不使用任何 js 函数的情况下呈现的,在我的 js 文件中只是自定义 data-formatter

我已尝试 运行 您在 https://live.bootstrap-table.com/ 中提供的输入,并且过滤器控件仅在删除 data-searchable="false"(或将其设置为 true)后才起作用。

因此您应该删除 data-searchable="false" 或将其设置为 true

在我的例子中,filter-control 由于 data-height 而无法正常工作。我删除了 data-height 并且有效。