SelectField
Finds and selects a single option by typing.
When to use
- Choose one item from a known list of values.
Examples
Select a delivery method
Loading the example
<k:SelectField label="Delivery" selectedKey="pickup" change=".onChange">
<core:Item key="pickup" text="Pickup"/>
<core:Item key="carrier" text="Carrier"/>
</k:SelectField>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.SelectFieldChange", {
onChange(event) {
Toast.show(event.getParameter("key") === "pickup" ? "Pickup selected" : "Carrier selected");
}
}));Find a warehouse
Loading the example
<k:SelectField label="Warehouse" required="true" placeholder="Search by name" items="{path: '/options', templateShareable: false}" change=".onChange">
<core:Item key="{key}" text="{text}"/>
</k:SelectField>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.SelectFieldChange", {
onChange(event) {
const field = event.getSource();
const option = field.getItems().find((item) => item.getKey() === event.getParameter("key"));
if (option) Toast.show(option.getText());
}
}));API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
selectedKey | string | Key of the selected option | |
label | string | Field label | |
placeholder | string | Placeholder | |
help | string | Supporting text | |
error | string | Validation message | |
required | boolean | false | Whether a selection is required |
enabled | boolean | true | Whether the field can be used |
Aggregations
| Name | Type | Description |
|---|---|---|
items | sap.ui.core.Item[] | Available options |
Events
| Name | Type | Description |
|---|---|---|
change | key: string | Selection changed |