Grid Column UIs¶
Some pre-built classes are included for quickly customizing a grid on screen.
The extools.ui.callback_column.CallbackColumnUI
adds a column to
the grid that is populated with a callback. It looks after the screen and
column setup, and calls the callback to popluate the cell whenever a value is
requested. The callback receives the grid edit event and data source as
arguments.
The extools.ui.optfield_column.OptfieldColumnUI
adds a column to
the grid that is populated with an optional field. The UI supports both
editable and non-editable cells and automatically writes back values to the
optional field data source.
The extools.ui.optfield_column.OptfieldMultiColumnUI
adds columns
to the grid that are populated optional fields. The UI supports both editable
and non-editable cells and automatically writes back values to the optional
field data source.
The extools.ui.datasource_column.DatasourceColumnUI
adds a column
that is populated with a datasource field - any datasource, it need not be the
one that backs the grid.
-
class
extools.ui.callback_column.
CallbackColumnUI
(ds, grid_control_name, fields)[source]¶ Callback Column UI adds a column to a grid populated with a callback.
Parameters: - ds (str) – Data source name.
- grid_control_name (str) – Name of the grid control to add a column to.
- fields ([{'caption': str, 'hijack': str, 'callback': function}, ..]) – a list of dictionaries containing the field definitions.
To use the CallbackColumn UI, create a new Screen script that instantiates an instance of the class, customizing it with the arguments.
Below is an example of adding a column, Qty in Ea. to the O/E Order Entry grid, that is populated with the quantity ordered in eaches, regardless of the line’s Unit of Measure.
# OE1100 from accpac import * from extools.ui.callback_column import CallbackColumnUI DATASOURCE = "adsOEORDD" GRID_CONTROL = "avlOEORDDdetail1" def quantity_in_eaches_callback(event, datasource): qty = datasource.get("QTYORDERED") if qty: return qty * datasource.get("UNITCONV") return 0 fields = [{ 'caption': "Qty in Ea.", 'hijack': 'ITEM', 'callback': quantity_in_eaches_callback },] def main(*args, **kwargs): CallbackColumnUI(DATASOURCE, GRID_CONTROL, fields)
-
class
extools.ui.optfield_column.
OptfieldColumnUI
(caption, optional_field, optf_datasource, grid_control_name, hijack='ITEM', default='', editable=False)[source]¶ Optfield Column UI adds a column populated with a optional field value.
Parameters: - caption (str) – Column caption.
- optional_field (str) – the name of the data source field.
- optf_datasource (str) – Optional field datasource name.
- grid_control_name (str) – Name of the grid control to add a column to.
- hijack (str) – Existing grid column to hijack.
- default (object) – Default value for the field.
- editable (bool) – Allow field to be edited?
To use the OptfieldColumn UI, create a new Screen script that initializes an instance of the class, customizing it with the arguments.
Below is an example of adding a column, Warranty, to the O/E Order Entry grid, that is populated with the WARRANTY optional field for the line.
# OE1100 from accpac import * from extools.ui.optfield_column import OptfieldColumnUI CAPTION = "Warranty" OPTFIELD = "WARRANTY" OPTF_DATASOURCE = "dsOEORDDO" GRID_CONTROL = "avlOEORDDdetail1" HIJACK_COLUMN = "ITEM" def main(*args, **kwargs): OptfieldColumnUI(CAPTION, OPTFIELD, OPTF_DATASOURCE, GRID_CONTROL, HIJACK, default="", editable=True)
-
class
extools.ui.optfield_multicolumn.
OptfieldMultiColumnUI
(optf_datasource, grid_control_name, columns)[source]¶ Optfield Column UI adds a column populated with a optional field value.
Parameters: - optf_datasource (str) – Optional field datasource name.
- grid_control_name (str) – Name of the grid control to add a column to.
- columns (dict) – Columns to create
To use the OptfieldMultiColumn UI, create a new Screen script that initializes an instance of the class, passing the column configuration as a dictionary.
Below is an example of adding two columns, Warranty and Warranty Period, to the O/E Order Entry grid, that is populated with the WARRANTY optional field for the line.
# OE1100 from accpac import * from extools.ui.optfield_column import OptfieldMultiColumnUI COLUMNS = { "Warranty": { 'optional_field': 'WARRANTY', 'default': False, 'editable': False, 'hijack': 'LOCATION' }, "Warranty Period": { 'optional_field': 'WARRANTYPRD', 'default': "60 Days", 'editable': True, 'hijack': 'ITEM', }, OPTF_DATASOURCE = "dsOEORDDO" GRID_CONTROL = "avlOEORDDdetail1" def main(*args, **kwargs): OptfieldMultiColumnUI(OPTF_DATASOURCE, GRID_CONTROL, COLUMNS)
-
class
extools.ui.datasource_column.
DatasourceColumnUI
(caption, ds, grid_control_name, hijack, gettext_callback)[source]¶ Datasource Column UI adds a column populated with a datasource field.
The datasource does not need to be the same datasource as
Parameters: - caption (str) – Column caption.
- grid_ds – Data source name.
- grid_control_name (str) – Name of the grid control to add a column to.
- hijack (str) – Existing grid column to hijack.
- field (str) – the name of the data source field.
To use the DatasourceColumn UI, create a new Screen script that initializes an instance of the class, customizing it with the arguments.
Below is an example of adding a column, Unit Conversion to the O/E Order Entry grid, that is populated with the unit conversion for the line.
# OE1100 from accpac import * from extools.ui.datasource_column import DatasourceColumnUI CAPTION = "Unit Conversion" DATASOURCE = "adsOEORDD" GRID_CONTROL = "avlOEORDDdetail1" HIJACK_COLUMN = "ITEM" FIELD = "UNITCONV" def main(*args, **kwargs): DatasourceColumnUI(CAPTION, DATASOURCE, GRID_CONTROL, HIJACK, FIELD)