NumberField
Edits a number using the active UI5 number format.
When to use
- Collect quantities with a unit, a step size or an allowed range.
Examples
Count items
Loading the example
<k:NumberField label="Quantity" value="2" min="0" change=".onChange"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.NumberFieldChange", {
onChange(event) {
Toast.show("Quantity updated");
}
}));Set the parcel weight
Loading the example
<k:NumberField label="Parcel weight" value="2.5" unit="kg" min="0" max="25"
step="0.5" decimals="1" help="Maximum 25 kg per parcel." change=".onWeight"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast", "sap/ui/core/format/NumberFormat"], (Controller, Toast, NumberFormat) => Controller.extend("sample.ParcelWeight", {
onWeight(event) {
const format = NumberFormat.getFloatInstance({ minFractionDigits: 1, maxFractionDigits: 1 });
Toast.show(format.format(event.getParameter("value")) + " kg");
}
}));API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
value | float | 0 | Numeric value |
label | string | Field label | |
unit | string | Displayed unit | |
decimals | int | 0 | Number of decimal places |
step | float | 1 | Step size |
min | float | -1e15 | Minimum value |
max | float | 1e15 | Maximum value |
help | string | Supporting text | |
error | string | Validation message | |
enabled | boolean | true | Whether the field can be used |
Events
| Name | Type | Description |
|---|---|---|
change | value: float | The value changed |