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

Table: Buňky založené na Cell vracejí i <td> element

Umožňuje <td> element modifikovat, například pomocí rowspan, nebo ho
naopak vůbec neuvést (například buňka na jejíž místo sahá rowspan jiné).
parent 13e779ab
No related branches found
No related tags found
1 merge request!17Výsledkovka pomocí mo.web.table
This commit is part of merge request !17. Comments created here will be created in the context of that merge request.
...@@ -37,7 +37,7 @@ class Cell: ...@@ -37,7 +37,7 @@ class Cell:
return self.text return self.text
def to_html(self) -> str: def to_html(self) -> str:
return escape(self.text) return '<td>' + escape(self.text)
class Row: class Row:
...@@ -63,7 +63,7 @@ class CellLink(Cell): ...@@ -63,7 +63,7 @@ class CellLink(Cell):
self.hint = hint self.hint = hint
def to_html(self) -> str: def to_html(self) -> str:
a = '<a href="' + escape(self.url) + '"' a = '<td><a href="' + escape(self.url) + '"'
if self.hint: if self.hint:
a += ' title="' + escape(self.hint) + '"' a += ' title="' + escape(self.hint) + '"'
return a + '>' + escape(self.text) + '</a>' return a + '>' + escape(self.text) + '</a>'
...@@ -81,7 +81,7 @@ class CellCheckbox(Cell): ...@@ -81,7 +81,7 @@ class CellCheckbox(Cell):
self.checked = checked self.checked = checked
def to_html(self) -> str: def to_html(self) -> str:
ch = f'<input type="checkbox" name="{self.name}" value="{self.value}"' ch = f'<td><input type="checkbox" name="{self.name}" value="{self.value}"'
if self.checked: if self.checked:
ch += ' checked' ch += ' checked'
return ch + '>' return ch + '>'
...@@ -113,10 +113,9 @@ class Table: ...@@ -113,10 +113,9 @@ class Table:
for c in self.columns: for c in self.columns:
val = r.get(c.key) val = r.get(c.key)
if isinstance(val, Cell): if isinstance(val, Cell):
vals = val.to_html() tab.append(val.to_html())
else: else:
vals = escape(str(val)) tab.append(f'\t<td>{escape(str(val))}')
tab.append(f'\t<td>{vals}')
tab.append('</table>') tab.append('</table>')
if self.show_downlink: if self.show_downlink:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment