class FooTable(Table): a = Column.number( ) # This is a shortcut that results in the css class "rj" (for right justified) being added to the header and cell b = Column() c = Column(cell__format=lambda value, **_: value[-1] ) # Display the last value of the tuple sum_c = Column(cell__value=lambda row, **_: sum(row.c), sortable=False) # Calculate a value not present in Foo
class BarTable(Table): select = Column.select() # Shortcut for creating checkboxes to select rows b__a = Column.number( # Show "a" from "b". This works for plain old objects too. filter__include=True, # put this field into the query language ) c = Column( bulk__include=True, # Enable bulk editing for this field filter__include=True, )
class FooTable(Table): # I can add checkboxes to each row s = Column.select() a = Column.number( ) # This is a shortcut that results in the css class "rj" (for right justified) being added to the header and cell b = Column() c = Column(cell__format=lambda value, **_: value[-1] ) # Display the last value of the tuple sum_c = Column(cell__value=lambda row, **_: sum(row.c), sortable=False) # Calculate a value not present in Foo class Meta: page_size = 3 # And register a button that will get the selection passed in its post_handler bulk__actions__print = Action.primary( display_name='print me', post_handler=bulk__actions__print__post_handler)
class BarTable(Table): select = Column.select( ) # Shortcut for creating checkboxes to select rows b__a = Column.number( ) # Show "a" from "b". This works for plain old objects too. b = Column.from_model( model=TBar, model_field_name='b', bulk__include=True, filter__include=True, ) c = Column(bulk__include=True) # The form is created automatically d = Column( display_name='Display name', attr__class__css_class=True, header__url='https://docs.iommi.rocks', sortable=False, group='Foo', auto_rowspan=True, filter__include=True, cell__value=lambda row, **_: row.b.a // 3, cell__format=lambda value, **_: '- %s -' % value, cell__attrs__class={'text-center': True}, cell__attrs__title='cell title', cell__url='url', cell__url_title='cell url title', ) e = Column(group='Foo', cell__value='explicit value', sortable=False) f = Column(include=False, sortable=False) g = Column(attr='c', sortable=False) django_templates_for_cells = Column( sortable=False, cell__value=None, cell__template='kitchen_sink_cell_template.html', group='Bar', ) class Meta: title = 'Kitchen sink' _name = 'bar' page_size = 20