Skip to content
Snippets Groups Projects
Commit 24a65da5 authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Table: Možnost definovat class vytvářené tabulky

parent 94dd29ac
Branches
No related tags found
1 merge request!17Výsledkovka pomocí mo.web.table
...@@ -7,7 +7,6 @@ from markupsafe import Markup ...@@ -7,7 +7,6 @@ from markupsafe import Markup
from typing import Any, Dict, Sequence, Optional, Iterable, Union from typing import Any, Dict, Sequence, Optional, Iterable, Union
import urllib.parse import urllib.parse
import werkzeug.exceptions import werkzeug.exceptions
from werkzeug.utils import html
from mo.csv import FileFormat from mo.csv import FileFormat
import mo.db as db import mo.db as db
...@@ -92,15 +91,21 @@ class Table: ...@@ -92,15 +91,21 @@ class Table:
rows: Iterable[Row] rows: Iterable[Row]
filename: str filename: str
show_downlink: bool show_downlink: bool
table_class: str
def __init__(self, columns: Sequence[Column], rows: Iterable[Row], filename: str, show_downlink: bool = True): def __init__(
self, columns: Sequence[Column], rows: Iterable[Row],
filename: str, show_downlink: bool = True,
table_class: str = "data"
):
self.columns = columns self.columns = columns
self.rows = rows self.rows = rows
self.filename = filename self.filename = filename
self.show_downlink = show_downlink self.show_downlink = show_downlink
self.table_class = table_class
def to_html(self) -> str: def to_html(self) -> str:
tab = ['<table class=data>', '<thead>', '<tr>'] tab = [f'<table class="{self.table_class}">', '<thead>', '<tr>']
for c in self.columns: for c in self.columns:
tab.append(f'\t<th>{c.title}') tab.append(f'\t<th>{c.title}')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment