如何在 Datatable 中渲染图像 link
How to render an image link in Datatable
我在烧瓶应用程序中有以下 table。第一列应该呈现一个完整的链接语句,例如:
<a href ="https://www.website.com/i=2xyz2g" target="_blank"> <img src="/static/assets/img/abc.jpg" width="100" height="100"></a>
数据来自查询:
Table 看起来是这样的:
|img | Title |
-----------------------------------------------
| the <a> script above goes here | some text|
我想编写 javascript 来渲染 image/link。
<table id="table_id" class="display compact" style="width:100%">
<thead>
<tr>
{% for col in img_list_cols %}
<th>{{col}}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in img_list_rows %}
<tr>
{% for row_data in row %}
<td>{{row_data}}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
您可以使用 Jinja safe
过滤器,例如..
<td>{{row_data|safe}}</td>
我在烧瓶应用程序中有以下 table。第一列应该呈现一个完整的链接语句,例如:
<a href ="https://www.website.com/i=2xyz2g" target="_blank"> <img src="/static/assets/img/abc.jpg" width="100" height="100"></a>
数据来自查询: Table 看起来是这样的:
|img | Title |
-----------------------------------------------
| the <a> script above goes here | some text|
我想编写 javascript 来渲染 image/link。
<table id="table_id" class="display compact" style="width:100%"> <thead> <tr> {% for col in img_list_cols %} <th>{{col}}</th> {% endfor %} </tr> </thead> <tbody> {% for row in img_list_rows %} <tr> {% for row_data in row %} <td>{{row_data}}</td> {% endfor %} </tr> {% endfor %} </tbody> </table>
您可以使用 Jinja safe
过滤器,例如..
<td>{{row_data|safe}}</td>