namespace sap.ui.model.odata.type

Control sample: sap.ui.model.odata.type
Visiblity: public
Available since: N/A
Module: sap/ui/model/odata/type/ODataType
Application Component: CA-UI5-COR

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:

TypeDescription
stringThe value is converted to a string, so that it can be displayed in an input field. Supported by all types.
booleanThe value is converted to a Boolean, so that it can be displayed in a checkbox. Only supported by sap.ui.model.odata.type.Boolean.
intThe value is converted to an integer (as number). May cause truncation of decimals and overruns. Supported by all numeric types.
floatThe value is converted to a number. Supported by all numeric types.
objectThe 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.
anyA 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.


Nodes Overview

Node Description
sap.ui.model.odata.type.Boolean

This class represents the OData primitive type Edm.Boolean.

sap.ui.model.odata.type.Byte

This class represents the OData primitive type Edm.Byte.

sap.ui.model.odata.type.Currency

This class represents the Currency composite type with the parts amount, currency, and currency customizing.

sap.ui.model.odata.type.Date

This class represents the OData V4 primitive type Edm.Date.

sap.ui.model.odata.type.DateTime

This class represents the OData V2 primitive type Edm.DateTime.

sap.ui.model.odata.type.DateTimeBase

This is an abstract base class for the OData primitive types Edm.DateTime and Edm.DateTimeOffset.

sap.ui.model.odata.type.DateTimeOffset

This class represents the OData primitive type Edm.DateTimeOffset.

sap.ui.model.odata.type.Decimal

This class represents the OData primitive type Edm.Decimal.

sap.ui.model.odata.type.Double

This class represents the OData primitive type Edm.Double.

sap.ui.model.odata.type.Guid

This class represents the OData primitive type Edm.Guid.

sap.ui.model.odata.type.Int

This is an abstract base class for integer-based OData primitive types like Edm.Int16 or Edm.Int32.

sap.ui.model.odata.type.Int16

This class represents the OData primitive type Edm.Int16.

sap.ui.model.odata.type.Int32

This class represents the OData primitive type Edm.Int32.

sap.ui.model.odata.type.Int64

This class represents the OData primitive type Edm.Int64.

sap.ui.model.odata.type.ODataType

This class is an abstract base class for all OData primitive types (see OData V4 Edm Types and OData V2 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 Edm.SByte.

sap.ui.model.odata.type.Single

This class represents the OData primitive type Edm.Single.

sap.ui.model.odata.type.Stream

This class represents the OData V4 primitive type Edm.Stream .

sap.ui.model.odata.type.String

This class represents the OData primitive type Edm.String.

sap.ui.model.odata.type.Time

This class represents the OData V2 primitive type Edm.Time.

sap.ui.model.odata.type.TimeOfDay

This class represents the OData V4 primitive type Edm.TimeOfDay .

sap.ui.model.odata.type.Unit

This class represents the Unit composite type with the parts measure, unit, and unit customizing.


Methods Overview

Method Description