The sap.ui.comp.smartfield.SmartField control offers a wrapper for other controls using OData metadata to determine which control has to be instantiated and makes it possible to add input-enabled fields to an application.
For more information about this control, see the API Reference in the Demo Kit and the sample in the Explored app in the Demo Kit.
For more information about annotations for this control, see the API Reference in the Demo Kit.
Hosting controls for editing and displaying values of OData properties
Providing value help automatically
Performing input checks
In addition, the SmartField control implements field control and supports message handling.
The SmartField control can be used in the following ways:
As a standalone control, for example, in XML views
In combination with a SmartForm control
In combination with a SmartTable control
Used in particular as cell editor in editing scenarios.
The SmartField control selects a control for displaying and a control for editing the OData property to which they are bound. The main criterion for selecting nested controls is the EDM type of the OData property to which a SmartField control is bound.
Binding
The OData property that a SmartField control manages is determined by the binding of the value property of the control. Here, complex properties are supported, which are arbitrarily and deeply nested.
The SmartField control allows for binding of navigation properties.
The entity set to which the bindings are related is either specified in the entitySet attribute of the control or derived from the binding context at runtime.
When binding the SmartField control against the OData service property of type Edm.Boolean, and if SmartField control is in read-only mode, static texts are used for visual representation. In addition, a configuration parameter in the SmartField control can define the properties of the static texts of the CheckBox, such as Yes/No or True/False. For the SmartForm control, the custom data can be used for this purpose.
EDM Type |
Control |
---|---|
Edm.Boolean |
sap.m.CheckBox |
Edm.Int16 |
sap.m.Input |
Edm.Int32 |
|
Edm.Int64 |
|
Edm.SByte |
|
Edm.Byte |
|
Edm.Single |
|
Edm.Float |
|
Edm.Double |
|
Edm.Decimal |
|
Edm.DateTime |
|
Edm.DateTimeOffset |
|
Edm.String |
Configuration
The SmartField control provides the option to overwrite the default behavior for control selection by using a specific configuration.
You have the following options:
If the relevant OData property is of type Edm.String or Edm.Boolean, the SmartField control can be configured to render a combo box.
If the relevant OData property is of type Edm.DateTime, the SmartField control can be configured to render a date picker.
In addition, the display format of the date in the date picker can also be configured.
EDM Type |
Control |
---|---|
Edm.Boolean |
sap.m.CheckBox |
Edm.Int16 |
sap.m.Text |
Edm.Int32 |
|
Edm.Int64 |
|
Edm.SByte |
|
Edm.Byte |
|
Edm.Single |
|
Edm.Float |
|
Edm.Double |
|
Edm.Decimal |
|
Edm.DateTime |
|
Edm.DateTimeOffset |
|
Edm.String |
Field Control
The field control handles the visual representation of SmartField controls, such as:
Whether input is mandatory
Whether the controls are read-only
Whether the controls are hidden as defined by the SAP Fiori user interface programming model
The following attributes are available to implement field control:
Enabled
Toggles from display to edit mode.
Hides the SmartField control.
Determines whether input is required.
Consumers of the SmartField control can further adapt the runtime behavior by binding these attributes.
The behavior can only be made more restrictive on client side, for example, if an OData property is mandatory, this cannot be overwritten on SmartField control level.