flask_table icon indicating copy to clipboard operation
flask_table copied to clipboard

column header with spaces

Open michaelmarzec opened this issue 3 years ago • 2 comments

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'?

michaelmarzec avatar Jan 25 '22 04:01 michaelmarzec

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 spacesDescription with with spaces
Name1Description1

plumdog avatar Jan 25 '22 10:01 plumdog

Understood - was misinterpreting the use of the Col() function. Thank you very much for the quick response!

michaelmarzec avatar Jan 25 '22 23:01 michaelmarzec