小编Mn2*_*n2C的帖子

如何使 bootstrap-table-filter-control 与 Flask、Jinja 和 Dataframe 一起使用

我正在使用 python Flask render_template 返回一个 html 页面作为我的 python 应用程序的路径,并且在 html 中我想使用 bootstrap-table-filter-control,如此处的 bootstrap 示例中所述。然而,给出的示例似乎使用本地 json 文件中的表。这是示例中给出的代码:

<link href="https://unpkg.com/bootstrap-table@1.16.0/dist/bootstrap-table.min.css" rel="stylesheet">

<script src="https://unpkg.com/bootstrap-table@1.16.0/dist/bootstrap-table.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.16.0/dist/extensions/filter-control/bootstrap-table-filter-control.min.js"></script>

<table
  id="table"
  data-url="json/data1.json"   ## this looks like the code to get the table's data
  data-filter-control="true"
  data-show-search-clear-button="true">
  <thead>
    <tr>
      <th data-field="id">ID</th>
      <th data-field="name" data-filter-control="input">Item Name</th>
      <th data-field="price" data-filter-control="select">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  $(function() {
    $('#table').bootstrapTable()
  })
</script>
Run Code Online (Sandbox Code Playgroud)

我该如何更换

数据url =“json/data1.json”

使用从 main.py 应用程序传递的 python 数据框中的我自己的表?我在我的 html 中尝试了以下方法,但它不起作用:

        {% for table in tables %}
            <table id="table" …
Run Code Online (Sandbox Code Playgroud)

html python jinja2 flask bootstrap-table

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

bootstrap-table ×1

flask ×1

html ×1

jinja2 ×1

python ×1