Skip to content
Snippets Groups Projects
Commit b4a58c08 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Add the method configure_column in GridModifier

parent c98b319a
No related branches found
No related tags found
No related merge requests found
...@@ -123,6 +123,12 @@ formModifier.configure(buttonAlign='right', ...@@ -123,6 +123,12 @@ formModifier.configure(buttonAlign='right',
height=380, height=380,
defaults={'height': 320}) 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 # Define a column template for the publications grid
# #
......
...@@ -141,13 +141,17 @@ class CfgSvc(BaseSvc): ...@@ -141,13 +141,17 @@ class CfgSvc(BaseSvc):
grid_modifiers = self.environment['plugins'].dbui.grid_modifiers grid_modifiers = self.environment['plugins'].dbui.grid_modifiers
if tablename in grid_modifiers: if tablename in grid_modifiers:
configure_columns = grid_modifiers[tablename].configure_columns
delete_columns = grid_modifiers[tablename].delete_columns delete_columns = grid_modifiers[tablename].delete_columns
template_columns = grid_modifiers[tablename].template_columns template_columns = grid_modifiers[tablename].template_columns
# standard column # standard column
for fieldname in db[tablename].fields: for fieldname in db[tablename].fields:
if fieldname not in delete_columns: 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 # template column
for el in template_columns: for el in template_columns:
......
...@@ -48,6 +48,7 @@ class GridModifier(Modifier): ...@@ -48,6 +48,7 @@ class GridModifier(Modifier):
""" """
Modifier.__init__(self, GRID_MODIFIERS, tablename) Modifier.__init__(self, GRID_MODIFIERS, tablename)
self.data.configure_columns = {}
self.data.delete_columns = [] self.data.delete_columns = []
self.data.grid_filters = [] self.data.grid_filters = []
self.data.hidden_columns = [] self.data.hidden_columns = []
...@@ -67,6 +68,17 @@ class GridModifier(Modifier): ...@@ -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): def delete_columns(self, *fields):
"""Delete the columns in the Ext.grid.GridPanel widget. """Delete the columns in the Ext.grid.GridPanel widget.
Each column is identified by its database field name. Each column is identified by its database field name.
......
--------------------------------- CHANGE LOG ---------------------------------- --------------------------------- CHANGE LOG ----------------------------------
0.4.x (Rev)
- Improve the GridModifier to modify column parameters.
0.4.2 (Oct 11) 0.4.2 (Oct 11)
- Migrate to git and to ExtJS 3.4 - Migrate to git and to ExtJS 3.4
- Backport the modifiers syntax developped in the branch 0.5.x - Backport the modifiers syntax developped in the branch 0.5.x
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment