Segmented
Switches between a few mutually exclusive options.
kor/ui/SegmentedSource
When to use
- Switch the time range or display mode for the same data.
Examples
Switch units of time
<k:Segmented label="Period" selectedKey="day" change=".onChange">
<core:Item key="day" text="Day"/>
<core:Item key="week" text="Week"/>
</k:Segmented>
sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.SegmentedChange", {
onChange(event) {
Toast.show(event.getParameter("key") === "day" ? "Daily period" : "Weekly period");
}
}));
Switch between order totals
<k:Stack gap="10">
<k:Segmented label="Report period" selectedKey="day" change=".onChange">
<core:Item key="day" text="Today"/>
<core:Item key="week" text="This week"/>
</k:Segmented>
<k:Stat label="Orders received" value="{/total}"/>
</k:Stack>
sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.OrderPeriod", {
onChange(event) {
const daily = event.getParameter("key") === "day";
this.getView().getModel().setProperty("/total", daily ? 42 : 270);
Toast.show(daily ? "Showing today" : "Showing this week");
}
}));
API
Properties
| Name | Type | Default | Description |
|---|
selectedKey | string | | Key of the selected option |
label | string | | Accessible name |
Aggregations
| Name | Type | Description |
|---|
items | sap.ui.core.Item[] | Available options |
Events
| Name | Type | Description |
|---|
change | key: string | Selection changed |
Methods
| Name | Description |
|---|
setSelectedKey(key: string): this | Sets the selected key and updates the indicator |
Related
TabsRadioGroup