def __init__(self, view, address_book_ui): super().__init__(view) self.rows = QueryAsSequence(Session.query(Address).order_by( Address.id), map_function=lambda address: Row(address)) self.add_child(H(view, 1, text='Addresses')) def make_link_widget(view, row): return A.from_bookmark( view, address_book_ui.get_edit_bookmark(row.address, description='Edit')) columns = [ StaticColumn(Field(label='Name'), 'name', sort_key=Address.name), StaticColumn(EmailField(label='Email'), 'email_address', sort_key=Address.email_address), StaticColumn(IntegerField(label='Zip'), 'zip_code', sort_key=Address.zip_code), DynamicColumn('', make_link_widget) ] table_layout = TableLayout(striped=True) data_table = DataTable(view, columns, self.rows, caption_text='All my friends', summary='Summary for screen reader', table_layout=table_layout, css_id='address_data') self.add_child(data_table)
def layout_for_contained_table(fixture): """You can specify a Layout to use for the actual table inside the DataTable.""" layout = TableLayout() data_table = DataTable(fixture.view, fixture.columns, fixture.data, 'my_css_id', table_layout=layout) vassert(data_table.table.layout is layout)
def __init__(self, view): super(MainWidget, self).__init__(view) data_table = DataTable(view, fixture.columns, fixture.data, items_per_page=fixture.items_per_page, caption_text='All my friends', summary='Summary for screen reader', css_id='my_table_data') self.add_child(data_table)
def test_layout_for_contained_table(web_fixture, data_table_fixture): """You can specify a Layout to use for the actual table inside the DataTable.""" layout = TableLayout( heading_theme='light' ) # heading_theme is here to give coverage of a previous bug data_table = DataTable(web_fixture.view, data_table_fixture.columns, data_table_fixture.data, 'my_css_id', table_layout=layout) assert data_table.table.layout is layout