Show TOC

Smart FieldLocate this document in the navigation structure

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.

Overview

The SmartField control provides an efficient way to add input-enabled fields to an SAP Fiori application. The control automatically adjusts to the meta data of the underlying OData service, for example, by doing the following:
  • 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 arbitrarily and deeply nested, complex properties are supported.

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 deduced from the binding context at runtime.

Note

You can use any available predefined model for data binding in the SmartField control.

Table 1: Control Selection for Editing Use Cases

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

Annotations

The SmartField control supports several annotations:

  • Value list annotation

    The annotation determines whether a value help dialog and the type ahead function are available.
    • If the entitySet that is addressed in the value list annotation has in turn the sap:semantics annotation with value fixed-values, a combo box is rendered.

  • sap:semantics annotation

    The annotation is used to determine, for example, whether the SmartField control manages currencies.

  • Semantic object annotation

    The annotation is used to determine whether the SmartField control must manage a SmartLink control.

  • If the relevant OData property is of type Edm.DateTime and the sap:display-format annotation with the date value is used, a DatePicker control is rendered.
  • If the relevant OData property is of type Edm.String, the sap:display-format annotation with UpperCase is used.
  • If the relevant OData property is of a numeric EDM type, such as Edm.Decimal, scale and precision are used.

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.

    Table 2: Control Selection for Display Use Cases

    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.

  • Visible

    Hides the SmartField control.

  • Mandatory

    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.