Linked Select
<zn-linked-select>
ZnLinkedSelect
Linked selects offer options that depend on the value chosen in another select.
<zn-select id="department" name="department" label="Department" value="billing"> <zn-option value="billing">Billing</zn-option> <zn-option value="sales">Sales</zn-option> <zn-option value="support">Support</zn-option> </zn-select> <zn-linked-select linked-select="department" name="queue" label="Queue" options='{ "billing": {"generic": "Generic", "refunds": "Refunds"}, "sales": {"new-business": "New business"}, "support": {"generic": "Generic", "urgent": "Urgent"} }'></zn-linked-select>
Set linked-select to the id of the zn-select it depends on.
options maps each of that select’s values to the options to offer, as
value: label pairs. When the linked select changes, the first option of the new group is
selected.
Examples
Placeholder and Search
Linked selects take the same placeholder, clearable, search,
multiple and help-text options as a Select. Add
select-first to pick the first option when there is no value.
<zn-select id="country" label="Country" value="uk"> <zn-option value="uk">United Kingdom</zn-option> <zn-option value="us">United States</zn-option> </zn-select> <zn-linked-select linked-select="country" name="city" label="City" placeholder="Choose a city" help-text="Cities depend on the country" clearable search options='{ "uk": {"london": "London", "manchester": "Manchester", "leeds": "Leeds"}, "us": {"nyc": "New York", "chicago": "Chicago"} }'></zn-linked-select>
Properties
| Name | Description | Reflects | Type | Default |
|---|---|---|---|---|
defaultValue
|
The default value of the form control. Primarily used for resetting the form control. |
string | string[]
|
''
|
|
selectFirst
select-first
|
Automatically select the first option of the linked group when no value is set. |
boolean
|
false
|
|
multiple
|
Allows more than one option of the linked group to be selected. |
|
boolean
|
false
|
updateComplete |
A read-only promise that resolves when the component has finished updating. |