SAPUI5 supports simple types that are used together with OData models.
These types support OData Version 2.0 including relevant property facets as constraints. All types have the nullable constraint which specifies whether empty input is allowed. All other constraints are type specific.
DateTime, DateTimeOffset, and Time support format options as defined in DateFormat.
Decimal, Byte, SByte, Int16, Int32, Int64, Single, and Double support format options as defined in NumberFormat.
OData Type |
SAPUI5 Type Implementation |
---|---|
Edm.Boolean |
sap.ui.model.odata.type.Boolean For more information, see sap.ui.model.odata.type.Boolean in the API Reference. |
Edm.Byte |
sap.ui.model.odata.type.Byte For more information, see sap.ui.model.odata.type.Byte in the API Reference. |
Edm.DateTime |
sap.ui.model.odata.type.DateTime For more information, see sap.ui.model.odata.type.DateTime in the API Reference. |
Edm.DateTimeOffset |
sap.ui.model.odata.type.DateTimeOffset For more information, see sap.ui.model.odata.type.DateTimeOffset in the API Reference. |
Edm.Decimal |
sap.ui.model.odata.type.Decimal Note
Although the specific type does not limit the precision, some format options cause a precision loss. For more information, see the API Reference. For more information, see sap.ui.model.odata.type.Decimal in the API Reference. |
Edm.Double |
sap.ui.model.odata.type.Double (read-only) For more information, see sap.ui.model.odata.type.Double in the API Reference. |
Edm.Float |
sap.ui.model.odata.type.Single For more information, see sap.ui.model.odata.type.Single in the API Reference. |
Edm.Guid |
sap.ui.model.odata.type.Guid For more information, see sap.ui.model.odata.type.Guid in the API Reference. |
Edm.Int16 |
sap.ui.model.odata.type.Int16 For more information, see sap.ui.model.odata.type.Int16 in the API Reference. |
Edm.Int32 |
sap.ui.model.odata.type.Int32 For more information, see sap.ui.model.odata.type.Int32 in the API Reference. |
Edm.Int64 |
sap.ui.model.odata.type.Int64 Note
The Int64 data type supports 64-bit precision. However, some format options cause a loss of precision. For more information, see the API Reference. For more information, see sap.ui.model.odata.type.Int64 in the API Reference. |
Edm.SByte |
sap.ui.model.odata.type.SByte For more information, see sap.ui.model.odata.type.SByte in the API Reference. |
Edm.Single |
sap.ui.model.odata.type.Single (read-only) For more information, see sap.ui.model.odata.type.Single in the API Reference. |
Edm.String |
sap.ui.model.odata.type.String For more information, see sap.ui.model.odata.type.String in the API Reference. |
Edm.Time |
sap.ui.model.odata.type.Time For more information, see sap.ui.model.odata.type.Time in the API Reference. |
With XML templating, the data types are used by the sap.ui.model.odata.AnnotationHelper with the constraints defined in the OData metadata.
The following code snippet shows an excerpt from an XML template view:
<Label text="{path: 'Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"/> <Input value="{path: 'Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"/>
However, you can use these types independently in data bindings.
The following code snippet shows an excerpt from an XML view without XML templating:
<Label text="Birthday"/> <Input value="{path: 'Birthday', type: 'sap.ui.model.odata.type.DateTime', constraints: {displayFormat: 'Date', nullable: false}}"/>