Always add key as class to grid column headers; allow literal label

This commit is contained in:
Lance Edgar 2017-06-01 19:29:32 -05:00
parent c8b8608dc7
commit d727efa6a0
2 changed files with 6 additions and 1 deletions

View file

@ -184,7 +184,11 @@ class AlchemyGrid(Grid):
Returns an iterator for all currently-visible columns. Returns an iterator for all currently-visible columns.
""" """
for field in self._fa_grid.render_fields.itervalues(): for field in self._fa_grid.render_fields.itervalues():
column = GridColumn(field.key, label=field.label(), if getattr(field, 'label_literal', False):
label = field.label_text
else:
label = field.label()
column = GridColumn(field.key, label=label,
title=getattr(field, '_column_header_title', None)) title=getattr(field, '_column_header_title', None))
column.field = field column.field = field
yield column yield column

View file

@ -588,6 +588,7 @@ class Grid(object):
kwargs['c'] = tags.link_to(column.label, '#', title=column.title) kwargs['c'] = tags.link_to(column.label, '#', title=column.title)
elif column.title: elif column.title:
kwargs['c'] = HTML.tag('span', title=column.title, c=column.label) kwargs['c'] = HTML.tag('span', title=column.title, c=column.label)
kwargs['class_'] = '{} {}'.format(kwargs.get('class_', ''), column.key)
return HTML.tag('th', **kwargs) return HTML.tag('th', **kwargs)
@property @property