I am struggling to add CSS classes to Wagtail StreamField
& TableBlock
(http://docs.wagtail.io/en/v1.8.1/reference/contrib/table_block.html).
Is the way to go to define a filter and use something like:
{{ child|className:"table table-bordered" }}
where className
is my custom filter?
The class attribute assigns one or more classnames to the <table> tag. Classnames are defined in a stylesheet or in a local <style> element.
Table class is an implementation of DbTable interface. It uses GDA to get access to a database's table description. In order to load data, you need to set a Gda. Connection and a table's name.
No, this isn't currently possible with the standard rendering of a TableBlock - the template used internally to render the block has hard-coded <table>
/ <tr>
/ <td>
tags with no class attributes. However, you could specify a custom template in your TableBlock
declaration, which would give you full control over the HTML:
StreamField([
# ...
('table', TableBlock(template='/path/to/custom/template.html')),
# ...
])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With