The types in this namespace are simple types corresponding to OData primitive types for both OData V2
and OData V4
(see "4.4 Primitive Types").
They can be used in any place where simple types are allowed (and the model representation matches), but they are of course most valuable when used in bindings to a sap.ui.model.odata.v2.ODataModel or sap.ui.model.odata.v4.ODataModel.
Example:
<Label text="ID"/> <Input value="{path : 'id', type : 'sap.ui.model.odata.type.String', constraints : {nullable : false, maxLength : 10}}"/> <Label text="valid through"/> <Input value="{path : 'validThrough', type : 'sap.ui.model.odata.type.DateTime', constraints : {displayFormat : 'Date'}}"/>
All types support formatting from the representation used in ODataModel ("model format") to various representations used by UI elements ("target type") and vice versa. Additionally they support validating a given value against the type's constraints.
The following target types may be supported:
Type | Description |
---|---|
string | The value is converted to a string , so that it can be displayed in an input field. Supported by all types. |
boolean | The value is converted to a Boolean , so that it can be displayed in a checkbox. Only supported by sap.ui.model.odata.type.Boolean. |
int | The value is converted to an integer (as number ). May cause truncation of decimals and overruns. Supported by all numeric types. |
float | The value is converted to a number . Supported by all numeric types. |
object | The value is converted to a Date so that it can be displayed in a date or time picker. Supported by sap.ui.model.odata.type.Date and sap.ui.model.odata.type.DateTimeOffset since 1.69.0. |
any | A technical format. The value is simply passed through. Only supported by format , not by parse . Supported by all types. |
All constraints relevant for OData V2 may be given as strings besides their natural types (e.g. nullable : "false"
or maxLength : "10"
). This makes the life of template processors easier, but is not needed for OData V4.
Handling of null
:
All types handle null
in the same way. When formatting to string
, it is simply passed through (and undefined
becomes null
, too). When parsing from string
, it is also passed through. Additionally, String and Guid convert the empty string to null
when parsing. validate
decides based on the constraint nullable
: If false
, null
is not accepted and leads to a (locale-dependent) ParseException
.
This ensures that the user cannot clear an input field bound to an attribute with non-nullable type. However it does not ensure that the user really entered something if the field was empty before.
Date
vs. DateTime
:
The type sap.ui.model.odata.type.Date is only valid for an OData V4 service. If you use the type for an OData V2 service, displaying is possible but you get an error message from server if you try to save changes.
For an OData V2 service use sap.ui.model.odata.type.DateTime with the constraint displayFormat: "Date"
to display only a date.
Node | Description |
---|---|
sap.ui.model.odata.type.Boolean |
This class represents the OData primitive type |
sap.ui.model.odata.type.Byte |
This class represents the OData primitive type |
sap.ui.model.odata.type.Currency |
This class represents the |
sap.ui.model.odata.type.Date |
This class represents the OData V4 primitive type |
sap.ui.model.odata.type.DateTime |
This class represents the OData V2 primitive type |
sap.ui.model.odata.type.DateTimeBase |
This is an abstract base class for the OData primitive types |
sap.ui.model.odata.type.DateTimeOffset |
This class represents the OData primitive type |
sap.ui.model.odata.type.Decimal |
This class represents the OData primitive type |
sap.ui.model.odata.type.Double |
This class represents the OData primitive type |
sap.ui.model.odata.type.Guid |
This class represents the OData primitive type |
sap.ui.model.odata.type.Int |
This is an abstract base class for integer-based OData primitive types like |
sap.ui.model.odata.type.Int16 |
This class represents the OData primitive type |
sap.ui.model.odata.type.Int32 |
This class represents the OData primitive type |
sap.ui.model.odata.type.Int64 |
This class represents the OData primitive type |
sap.ui.model.odata.type.ODataType |
This class is an abstract base class for all OData primitive types (see OData V4 Edm Types
|
sap.ui.model.odata.type.Raw |
This class represents a placeholder for all unsupported OData primitive types. |
sap.ui.model.odata.type.SByte |
This class represents the OData primitive type |
sap.ui.model.odata.type.Single |
This class represents the OData primitive type |
sap.ui.model.odata.type.Stream |
This class represents the OData V4 primitive type |
sap.ui.model.odata.type.String |
This class represents the OData primitive type |
sap.ui.model.odata.type.Time |
This class represents the OData V2 primitive type |
sap.ui.model.odata.type.TimeOfDay |
This class represents the OData V4 primitive type |
sap.ui.model.odata.type.Unit |
This class represents the |
Method | Description |
---|