flask table colapsable code example
Example 1: table html tages
<table>
<tr> <!-- This is the first row -->
<th>This is the heading</th>
<th>Next heading to the right</th>
</tr>
<tr> <!-- This is the second row -->
<td>This is where the table data goes</td>
<td>This is the second columns data</td>
</tr>
</table>
Example 2: flask sqlalchemy put data in html table
from flask_table import Table, Col
class ItemTable(Table):
name = Col('Name')
description = Col('Description')
class Item(object):
def __init__(self, name, description):
self.name = name
self.description = description
items = [Item('Name1', 'Description1'),
Item('Name2', 'Description2'),
Item('Name3', 'Description3')]
items = [dict(name='Name1', description='Description1'),
dict(name='Name2', description='Description2'),
dict(name='Name3', description='Description3')]
items = ItemModel.query.all()
table = ItemTable(items)
print(table.__html__())