From d727efa6a09ef4b4d6357b1b74befc03e6fc08dd Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 1 Jun 2017 19:29:32 -0500 Subject: [PATCH] Always add key as class to grid column headers; allow literal label --- tailbone/newgrids/alchemy.py | 6 +++++- tailbone/newgrids/core.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tailbone/newgrids/alchemy.py b/tailbone/newgrids/alchemy.py index a3d2a9f0..99d0aec6 100644 --- a/tailbone/newgrids/alchemy.py +++ b/tailbone/newgrids/alchemy.py @@ -184,7 +184,11 @@ class AlchemyGrid(Grid): Returns an iterator for all currently-visible columns. """ 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)) column.field = field yield column diff --git a/tailbone/newgrids/core.py b/tailbone/newgrids/core.py index 88382f50..58ed588b 100644 --- a/tailbone/newgrids/core.py +++ b/tailbone/newgrids/core.py @@ -588,6 +588,7 @@ class Grid(object): kwargs['c'] = tags.link_to(column.label, '#', title=column.title) elif column.title: kwargs['c'] = HTML.tag('span', title=column.title, c=column.label) + kwargs['class_'] = '{} {}'.format(kwargs.get('class_', ''), column.key) return HTML.tag('th', **kwargs) @property