Skip to main content
Version: V3 (Ignition 8.3)

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

ParameterTypeNullableDescription
objectListListFalseThe list of objects/dictionaries to format.
labelStringFalseThe key whose value is used as each option's label.
valueStringFalseThe 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 []