From 46c8887c3e92fa56c0108a52ec6636b070dbcbfe Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 1 Jun 2018 13:02:55 -0500 Subject: [PATCH] Set default column renderers for grid based on data types guess this really just moves that logic so it happens earlier --- tailbone/grids/core.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index 72964845..044d2302 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -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: