Skip to Content

SAPUI5 Smart Table - Smart Field make field mandatory with annotation

Is it possible to make a Property in SAPUI5 Smart Table mandatory so that a user can't leave a field empty while editing it?

I found out that sap:field-control should contain number a path expression to another property which contains the number. However this doesn't work:

<Property Name="NameLast" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Last name" sap:field-control="Name_fc" />
<Property Name="Name_fc" Type="Edm.Byte" />

Value of Name_fc property is '7'. I don't see any console error now, however I can still leave the input (NameLast) field empty without any validation and send it to OData service, which is not what I expect.

Here is a link to an example from sap where they use required fields. I have no idea though how they made it:

The field Name is required, but I don't see any "required" settings in metadata.xml nor in the View.

Another example with required Fields is here, but also here it is not obvisous for me how was it done:

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 19, 2018 at 03:38 PM

    The mandatory property of the entity has to be nullable="false".

    Like in this example:

                <Property Name="Name" Type="Edm.String" Nullable="false"
                    MaxLength="30" sap:label="Name" sap:creatable="false"
                    sap:quickinfo="Property annotation DataFieldWithUrl"
                    sap:updatable="true" sap:sortable="false" />
    Add comment
    10|10000 characters needed characters exceeded