Add support for column header title (tooltip) in new grids

This commit is contained in:
Lance Edgar 2016-04-06 21:15:54 -05:00
parent 073358417c
commit 7676312dd7
2 changed files with 7 additions and 3 deletions

View file

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

View file

@ -578,7 +578,9 @@ class Grid(object):
else:
kwargs['class_'] = 'sortable'
kwargs['data-sortkey'] = column.key
kwargs['c'] = tags.link_to(column.label, '#')
kwargs['c'] = tags.link_to(column.label, '#', title=column.title)
elif column.title:
kwargs['c'] = HTML.tag('span', title=column.title, c=column.label)
return HTML.tag('th', **kwargs)
@property
@ -685,9 +687,10 @@ class GridColumn(object):
Human-facing label for the column, i.e. displayed in the header.
"""
def __init__(self, key, label=None):
def __init__(self, key, label=None, title=None):
self.key = key
self.label = label or prettify(key)
self.title = title
def render(self, value):
"""