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

Deploy the tool customize_grid_with_template_column in the configuration service.

parent 39d7f0e9
No related branches found
No related tags found
No related merge requests found
......@@ -42,41 +42,68 @@ class CfgSvc(object):
setattr(self, '_%s' % key, pluginManager.dbui[key])
def _getColumnsModel(self, tablename):
""" Generate columns model required by the gridPanel widget.
The method return a list.
def _getColumn(self, tablename, fieldname):
""" Return a dictionary with the column model
required by the gridPanel widget.
"""
li = []
for fieldname in self._db[tablename].fields:
col = {}
field = self._db[tablename][fieldname]
col = {}
field = self._db[tablename][fieldname]
# column header
col["header"] = str(self._translate(field.label))
# replace foreign key by the pointing column
if self._is_foreign_field(tablename, fieldname):
k_tablename, k_fieldname, k_key = \
self._get_foreign_data(tablename, fieldname)
col["dataIndex"] = encode_field(k_tablename, k_fieldname)
# column header
col["header"] = str(self._translate(field.label))
# replace foreign key by the pointing column
if self._is_foreign_field(tablename, fieldname):
# standard column
else:
col["dataIndex"] = encode_field(tablename, fieldname)
col["sortable"] = True
k_tablename, k_fieldname, k_key = \
self._get_foreign_data(tablename, fieldname)
col["dataIndex"] = encode_field(k_tablename, k_fieldname)
# standard column
else:
col["dataIndex"] = encode_field(tablename, fieldname)
# hide the primary key
# and field which are not readable and not writable
if fieldname == "id" or ((not field.readable) and (not field.writable)):
col["sortable"] = True
# hide the primary key
# and field which are not readable and not writable
if fieldname == "id" or ((not field.readable) and (not field.writable)):
col["hidden"] = True
# Hide fields request customizing the grid
if tablename in self._hidden_columns:
if fieldname in self._hidden_columns[tablename]:
col["hidden"] = True
return col
li.append(col)
def _getColumnsModel(self, tablename):
""" Return the columns model required by the gridPanel widget
handling customize columns.
"""
li= []
# standard column
for fieldname in self._db[tablename].fields:
li.append(self._getColumn(tablename, fieldname))
# template column
if tablename in self._template_columns:
for el in self._template_columnd[tablename]:
data = self._template_columns[tablename]
col = {'xtype': 'templatecolumn',
'header': data.header,
'tpl': data.tpl,
'sortable': True}
li.insert(data.ipos, col)
return li
......
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