Value Binding
The DropDownTree value can either be a primitive (strings, numbers, or other) or a complex value (objects).
To set the value, apply any of the following approaches:
- Use the
value
property. If the value is set through thevalue
property, you have to hook up to thevalueChange
event and manually update the value of thevalue
property. - Use the
ngModel
value binding. If the value is set by thengModel
value binding, the framework will automatically update the corresponding field from the model after the value of the component changes. - Use the
formControlName
value binding available in the Reactive forms. If the value is set by theformControlName
value binding, the framework will automatically update the corresponding field from the form model after the value of the component changes.
The DropDownTree does not support the simultaneous usage of the
value
property and thengModel
value binding.
When binding the DropDownTree value, the component provides options for:
Primitive Values
If the value
is of a primitive type, the valuePrimitive
property needs to be set to true
and dataItem
must be provided. The value
property of the dataItem
will be associated with the valueField
and the text to display will be extracted from the textField
of the objects.
Primitive data types include:
String
Number
Undefined
Null
Heterogenous Data Type
When
valueField
andtextField
arestring[]
, always specifyvalueDepth
. If you do not provide a value for the field, the DropDownTree will look for the first property match fromdataItem
in thevalueField
which may result in an incorrect value match.
Object Values
If the DropDownTree is bound to a dataset of objects, its value will be an object of the same type.
The following table lists the valid configuration scenarios.
Data Type | Value | ValuePrimitive | ValueField | ValueDepth | DataItem |
---|---|---|---|---|---|
Hierarchical Homogenous | primitive | true | set | Not set | Set |
Hierarchical Homogenous | complex | Not set | set | Not set | Not set |
Hierarchical Heterogenous | primitive | true | set [Array ] | Set | Set |
Hierarchical Heterogenous | primitive | true | set [Array ] | Not set (inferred) | Set |
Hierarchical Heterogenous | complex | Not set | set [Array ] | Set | Not set |
Hierarchical Heterogenous | complex | Not set | set [Array ] | Not set (inferred) | Not set |
Flat | primitive | true | set | Not set | Set |
Flat | complex | Not set | set | Not set | Not set |