From e5356e749dd24b5312744b60cab312a93df64d3d Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Wed, 18 Mar 2015 19:53:57 +0100 Subject: [PATCH] [gen] List and grid fields: bugfixes. --- fields/dict.py | 7 +++++++ fields/list.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/fields/dict.py b/fields/dict.py index ce554bd..992e46f 100644 --- a/fields/dict.py +++ b/fields/dict.py @@ -74,6 +74,13 @@ class Dict(List): # while encoding/viewing this entry. self.keys = keys + def computeWidths(self, widths): + '''Set given p_widths or compute default ones if not given.''' + if not widths: + self.widths = [''] * (len(self.fields) + 1) + else: + self.widths = widths + def getFormattedValue(self, obj, value, layoutType='view', showChanges=False, language=None): '''Formats the dict value as a list of values''' diff --git a/fields/list.py b/fields/list.py index 33f31cd..a6776f3 100644 --- a/fields/list.py +++ b/fields/list.py @@ -99,6 +99,10 @@ class List(Field): field.layouts = field.formatLayouts(subLayouts) # One may specify the width of every column in the list. Indeed, using # widths and layouts of sub-fields may not be sufficient. + self.computeWidths(widths) + + def computeWidths(self, widths): + '''Set given p_widths or compute default ones if not given.''' if not widths: self.widths = [''] * len(self.fields) else: