Commit 80c975b7 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update converter.to_gridFilter to be able to instantiate any field widget.

parent 9d3dcb66
......@@ -29,6 +29,7 @@ from extjs import (Base,
Model,
PanelWithUrlSelector)
from gluon import current
from gluon.storage import Storage
from gluon.tools import PluginManager
from gridmodifier import ROW_NUMBERING
from helper import (encode_field,
......@@ -528,12 +529,21 @@ def to_gridFilter(table, **kwargs):
method :meth:`.GridModifier.append_filter`
and :meth:`.GridModifier.configure_filters`
A ``GridFilter`` is a collection of widget. Each of them is associated
to a database field. The configuration of the widget is similar to one use
in the form for the database field. The configuration of the widget can be
tuned via the keyword arguments.
The configuration of the widget can be fully specified, without any link
to the form. In that case, the keyword argument ``xtype`` has to be
defined.
Args:
table (gluon.dal.Table): database table
Keyword Args:
**kwargs (dict): any of the Ext JS configuration parameters of the
the :class:`.GridFilter`` class. They are applied in the following
the :class:`.GridFilter` class. They are applied in the following
order: constructor, modifiers, keyword arguments.
Returns:
......@@ -574,6 +584,19 @@ def to_gridFilter(table, **kwargs):
field = table[fieldname]
name = '[%s.%s]' % (tablename, fieldname)
# ....................................................................
#
# standalone configuration of the widget from the keyword arguments
#
extjs_filter = grid_filters.extjs_filters[i]
if 'xtype' in extjs_filter:
cfg = Storage(extjs_filter)
# ....................................................................
#
# configuration of the widget from the database form
#
else:
# get the standard configuration for the field
# ignore composite field set up for form
# ignore linked ComboBox set up for form
......@@ -603,21 +626,24 @@ def to_gridFilter(table, **kwargs):
cfg['emptyText'] = T('select...')
cfg['xtype'] = 'xcomboboxuserreset'
# prepare the name for the where close [table.field]
cfg['name'] = name
# field configuration option
cfg.update(grid_filters.extjs_filters[i])
# store information to customise the filter
# ....................................................................
#
# add dedicated information to customise the filter
#
cfg['filterComment'] = comment
cfg['filterOperator'] = operator
cfg['filterType'] = field.type
# prepare the name for the where close [table.field]
cfg['name'] = name
# copy the comment to be used as a tool tip
# when the plugin pFormToolTip is used
cfg['tipText'] = comment
# field configuration option
cfg.update(grid_filters.extjs_filters[i])
di.append_items(cfg)
# configuration options from the grid modifier
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment