tamaki.mes.utils.objListToDropdown
Description
Converts a list of objects (dictionaries) into the {'value', 'label'} format used by Perspective
dropdown components. The label and value parameters name which keys of each object supply the
option's label and value. The label is always converted to a string.
Syntax
tamaki.mes.utils.objListToDropdown(objectList, label, value)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
objectList | List | False | The list of objects/dictionaries to format. |
label | String | False | The key whose value is used as each option's label. |
value | String | False | The key whose value is used as each option's value. |
Returns
A List of {'value', 'label'} dictionaries.
Code Examples
# In a binding script transform: turn a list of MES objects into dropdown options
if value and len(value) > 0:
return tamaki.mes.utils.objListToDropdown(value, 'name', 'id')
else:
return []