Package reahl.web.bootstrap.tables

New in version 3.2.

Tables are Widgets that show data items in rows arranged into aligned columns. This module includes tools to help transform data for display in a Table.

You can also display a Widget (such as a Button or Input) in a Table cell by using DynamicColumn.

The number of data items displayed in a Table can potentially be very large. DataTable solves this problem by only displaying a small portion of the data, allowing a user to page to different pages, each containing a suitably-sized smaller list. DataTable can also be set up to let a user sort data according to different columns.

Table

class reahl.web.bootstrap.tables.Table(view, caption_text=None, summary=None, css_id=None)

Tabular data displayed as rows broken into columns.

Parameters:
  • view – (See Widget)
  • caption_text – If text is given here, a caption will be added to the table containing the caption text.
  • summary – A textual summary of the contents of the table which is not displayed visually, but may be used by a user agent for accessibility purposes.
  • css_id – (See HTMLElement)

DynamicColumn

class reahl.web.bootstrap.tables.DynamicColumn(make_heading_or_string, make_widget, sort_key=None)

DynamicColumn defines a logical column of a table, specifying how its heading will be rendered, and how the cell in this column will be displayed for each data item in the table.

Parameters:
  • make_heading_or_string – A string to be used as heading for this column, or a single-argument callable that will be called (passing the current view) in order to compute a Widget to be displayed as heading of the column.
  • make_widget – A callable that takes two arguments: the current view, and an item of data of the current table row. It will be called to compute a Widget to be displayed in the current column for the given data item.
  • sort_key – If specified, this value will be passed to sort() for sortable tables.

StaticColumn

class reahl.web.bootstrap.tables.StaticColumn(field, attribute_name, sort_key=None)

StaticColumn defines a column whose heading and contents are derived from the given field.

Parameters:
  • field – The Field that defines the heading for this column, and which will also be used to get the data to be displayed for each row in this column.
  • attribute_name – The name of the attribute to which field should be bound to on each data item when rendering this column.
  • sort_key – If specified, this value will be passed to sort() for sortable tables.

DataTable

class reahl.web.bootstrap.tables.DataTable(view, columns, items, css_id, items_per_page=10, max_page_links=5, caption_text=None, summary=None, table_layout=None)

A table containing a potentially large set of data items. DataTable does not display all its items on the current page. It renders as a table spread over different pages between which a user can navigate, thus preventing a large data set sent back to a single page.

If a DynamicColumn is used to define the table also specifies a sort_key, the table is rendered with controls on that column heading that allows it to be sorted on that column. The sort operation applies to the entire dataset even though the user stays on the current page and only sees a subset of that data.

Parameters:
  • view – (See reahl.web.fw.Widget)
  • columns – The DynamicColumn instances that define the contents of the table.
  • items – A list containing objects represented in each row of the table.
  • css_id – (See HTMLElement)
  • items_per_page – The maximum number of rows allowed per page.
  • max_page_links – The maximum number of page links to show in the page menu.
  • caption_text – If given, a Caption is added with this text.
  • summary – If given, this text will be set as the summary of the contained Table (See Table).
  • table_layout – If given, the layout is applied to the contained Table.

TableLayout

class reahl.web.bootstrap.tables.TableLayout(dark=False, border='rows', compact=False, striped=False, highlight_hovered=False, responsive=False, heading_theme=None)

A Layout for customising details of how a Table is displayed.

Parameters:
  • dark – If True, table text is light text on dark background.
  • border – If set to ‘cells’, a border is rendered around each cell. When set to ‘rows’ (the default) only row delimeters are shown. If ‘borderless’, no borders are rendered. Allowed values: ‘rows’, ‘cells’ and ‘borderless’.
  • compact – If True, make the table more compact by cutting cell padding in half.
  • striped – If True, colour successive rows lighter and darker.
  • highlight_hovered – If True, a row is highlighted when the mouse hovers over it.
  • responsive – If True, activate horizontal scrolling. If set to a device class activate horizontal scrolling only for devices smaller than the device class. Allowed values : ‘xs’, ‘sm’, ‘md’, ‘lg’ and ‘xl’
  • heading_theme – One of ‘light’ or ‘dark’. A light heading is one with darker text on a lighter background.
customise_widget()

Override this method in subclasses to allow your Layout to change its Widget upon construction. There is no need to call super(), as the superclass implementation does nothing.

Caption

class reahl.web.bootstrap.tables.Caption(view, text=None, css_id=None)

An HTML caption element.

Styling

Renders as an HTML <caption> element.

Parameters:

Thead

class reahl.web.bootstrap.tables.Thead(view, css_id=None)

An HTML thead element. Contains the header of the table columns.

Parameters:

Tfoot

class reahl.web.bootstrap.tables.Tfoot(view, css_id=None)

An HTML tfoot element. Contains the footer of the table columns.

Parameters:

Tbody

class reahl.web.bootstrap.tables.Tbody(view, css_id=None)

An HTML tbody element. Contains the rows with data in the table.

Parameters:

Tr

class reahl.web.bootstrap.tables.Tr(view, css_id=None)

An HTML tr element represents one row of data in a table.

Parameters:

Td

class reahl.web.bootstrap.tables.Td(view, rowspan=None, colspan=None, css_id=None)

An HTML td element - a single cell of data inside a row of a table.

Parameters:

Th

class reahl.web.bootstrap.tables.Th(view, rowspan=None, colspan=None, css_id=None)

An HTML th element - a single cell heading for a column of a table.

Parameters:

Col

class reahl.web.bootstrap.tables.Col(view, span=None, css_id=None)

An HTML col element, defines a column in a table.

Parameters:

ColGroup

class reahl.web.bootstrap.tables.ColGroup(view, span=None, css_id=None)

An HTML colgroup element, defines a group of columns in a table.

Parameters: