flask_table
flask_table copied to clipboard
column header with spaces
Is there a way to use column headers that have a space in them?
For example, I'm using the sortableTable class and \Team_Name = Col('Team_Name), which works well. However, is there a way to use this library/function if I wanted to rename my column header to 'Team Name'?
Hi @michaelmarzec,
The string that you pass as the first argument to Col
is used as the table header, eg:
from flask_table import Table, Col
class ItemTable(Table):
name = Col('Name with spaces')
description = Col('Description with with spaces')
items = [{'name': 'Name1', 'description': 'Description1'}]
table = ItemTable(items)
print(table.__html__())
outputs:
<table>
<thead><tr><th>Name with spaces</th><th>Description with with spaces</th></tr></thead>
<tbody>
<tr><td>Name1</td><td>Description1</td></tr>
</tbody>
</table>
which is
Name with spaces | Description with with spaces |
---|---|
Name1 | Description1 |
Understood - was misinterpreting the use of the Col() function. Thank you very much for the quick response!