diff --git a/models/db_widgets.py b/models/db_widgets.py index 6f797ef1e1dc099207fa5d4ba8f9853af3a5ba1a..539eb1d6d3274b17c5624615101e99a00a63dce9 100755 --- a/models/db_widgets.py +++ b/models/db_widgets.py @@ -123,6 +123,12 @@ formModifier.configure(buttonAlign='right', height=380, defaults={'height': 320}) +# +# fine tune categories_aeres grid +# +gridModifier = dbui.GridModifier('categories_aeres') +gridModifier.configure_column('code', width=10) + # # Define a column template for the publications grid # diff --git a/modules/plugin_dbui/cfgsvc.py b/modules/plugin_dbui/cfgsvc.py index 686fea6b9d2eb1b7b7f9e4194d979a183739820d..791c3e3c47caf2ab4f08d5a27b9888d8088b558f 100755 --- a/modules/plugin_dbui/cfgsvc.py +++ b/modules/plugin_dbui/cfgsvc.py @@ -141,13 +141,17 @@ class CfgSvc(BaseSvc): grid_modifiers = self.environment['plugins'].dbui.grid_modifiers if tablename in grid_modifiers: + configure_columns = grid_modifiers[tablename].configure_columns delete_columns = grid_modifiers[tablename].delete_columns template_columns = grid_modifiers[tablename].template_columns # standard column for fieldname in db[tablename].fields: if fieldname not in delete_columns: - li.append(self._get_column(tablename, fieldname)) + model = self._get_column(tablename, fieldname) + if fieldname in configure_columns: + model.update(configure_columns[fieldname]) + li.append(model) # template column for el in template_columns: diff --git a/modules/plugin_dbui/gridmodifier.py b/modules/plugin_dbui/gridmodifier.py index 59a5abd597e1a5cfea2ba6b274f92df25896d593..46dc7f1bc8ab23d3ddddfe7978df98ebb71a6a06 100644 --- a/modules/plugin_dbui/gridmodifier.py +++ b/modules/plugin_dbui/gridmodifier.py @@ -48,6 +48,7 @@ class GridModifier(Modifier): """ Modifier.__init__(self, GRID_MODIFIERS, tablename) + self.data.configure_columns = {} self.data.delete_columns = [] self.data.grid_filters = [] self.data.hidden_columns = [] @@ -67,6 +68,17 @@ class GridModifier(Modifier): """ + def configure_column(self, fieldname, **kwargs): + """Modified the model of a given column. + This method is useful to fine tune column width for example. + + The keyword arguments defines the configuration option + of the underlying Ext.grid.Column + + """ + self.data.configure_columns[fieldname] = kwargs + + def delete_columns(self, *fields): """Delete the columns in the Ext.grid.GridPanel widget. Each column is identified by its database field name. diff --git a/static/plugin_dbui/CHANGELOG b/static/plugin_dbui/CHANGELOG index e0835b0e78358140e029274894ae27dc18bfc0b7..0cbefb0013f7c9e144d81bf555ed05ac69d7d921 100644 --- a/static/plugin_dbui/CHANGELOG +++ b/static/plugin_dbui/CHANGELOG @@ -1,5 +1,8 @@ --------------------------------- CHANGE LOG ---------------------------------- +0.4.x (Rev) + - Improve the GridModifier to modify column parameters. + 0.4.2 (Oct 11) - Migrate to git and to ExtJS 3.4 - Backport the modifiers syntax developped in the branch 0.5.x