Skip to main content

CnSearchSelect

A single picker drawn as a search field: a magnifier where the chevron was, and the results as rows with an icon or initials, a name, a secondary line and a check on the chosen one. Boards DqOverdragen ("Nieuw team": "Juridische zaken · 6 leden · bezwaar, beroep en Woo-advies") and DqNieuweZaak ("Aanvrager": "Henk Visser · Inwoner · Beukenlaan 3") draw it.

It wraps NcSelect, so typing, the keyboard, clearing and the accessible name work as in any other select.

Usage​

<CnSearchSelect
v-model="team"
:input-label="t('dossiq', 'New team')"
:options="[
{ id: 'legal', label: 'Juridische zaken', secondary: '6 leden · bezwaar, beroep en Woo-advies', avatar: true },
{ id: 'vth', label: 'Vergunningen', secondary: '9 leden', icon: 'AccountGroup' },
]" />

A host that searches itself listens to search, passes the results as options and sets :filterable="false".

In a form​

A single select field in CnFormDialog takes this look with look: "search", usually through fieldOverrides. optionSecondary is a template filled from each option ("{members} leden · {focus}"), optionAvatar: true draws the initials, optionIcon names one icon for every row. An option's own secondary, icon or avatar wins.

"fieldOverrides": {
"team": { "look": "search", "optionSecondary": "{members} leden · {focus}", "optionAvatar": true }
}

Props​

PropTypeDefaultDescription
modelValueString, Number or ObjectnullThe chosen option's id (or the option)
optionsArray[]{ id, label, secondary?, icon?, avatar? }: icon names a CnIcon, avatar: true draws the label's initials
inputLabelString''The field's label
labelOutsideBooleanfalseDraw the label above the field
inputIdStringundefinedThe input's id
placeholderString''Placeholder; "Search…" when empty
loadingBooleanfalseShow the spinner
clearableBooleantrueOffer a clear button
disabledBooleanfalseDisable the field
filterableBooleantrueFilter on the typed text; false when the host searches

Events​

EventPayloadDescription
update:modelValueid or nullThe picked option's id, null when cleared
searchStringThe typed text