Set default column renderers for grid based on data types
guess this really just moves that logic so it happens earlier
This commit is contained in:
parent
db645fb393
commit
46c8887c3e
|
@ -87,7 +87,7 @@ class Grid(object):
|
|||
self.enums = enums or {}
|
||||
|
||||
self.labels = labels or {}
|
||||
self.renderers = renderers or {}
|
||||
self.renderers = self.make_default_renderers(renderers or {})
|
||||
self.extra_row_class = extra_row_class
|
||||
self.linked_columns = linked_columns or []
|
||||
self.url = url
|
||||
|
@ -301,7 +301,7 @@ class Grid(object):
|
|||
column_formats['checkbox'] = self.checkbox_column_format
|
||||
|
||||
if self.renderers:
|
||||
kwargs['renderers'] = self.make_webhelpers_grid_renderers()
|
||||
kwargs['renderers'] = self.renderers
|
||||
if self.extra_row_class:
|
||||
kwargs['extra_record_class'] = self.extra_row_class
|
||||
if self.linked_columns:
|
||||
|
@ -325,16 +325,15 @@ class Grid(object):
|
|||
if key not in self.sorters])
|
||||
return grid
|
||||
|
||||
def make_webhelpers_grid_renderers(self):
|
||||
def make_default_renderers(self, renderers):
|
||||
"""
|
||||
Return a dict of renderers for the webhelpers grid. We honor any
|
||||
existing renderers which have already been set, but then we also try to
|
||||
supplement that by auto-assigning renderers based on underlying column
|
||||
type. Note that this special logic only applies to grids with a valid
|
||||
:attr:`model_class`.
|
||||
"""
|
||||
renderers = dict(self.renderers)
|
||||
Make the default set of column renderers for the grid.
|
||||
|
||||
We honor any existing renderers which have already been set, but then
|
||||
we also try to supplement that by auto-assigning renderers based on
|
||||
underlying column type. Note that this special logic only applies to
|
||||
grids with a valid :attr:`model_class`.
|
||||
"""
|
||||
if self.model_class:
|
||||
mapper = orm.class_mapper(self.model_class)
|
||||
for prop in mapper.iterate_properties:
|
||||
|
|
Loading…
Reference in a new issue