Skip to Content
0

SAPUI5 Smart Table - Smart Field make field mandatory with annotation

Apr 14, 2017 at 05:25 PM

454

avatar image

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:https://sapui5.netweaver.ondemand.com/sdk/explored.html#/sample/sap.ui.comp.sample.smartfield/preview

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:https://sapui5.netweaver.ondemand.com/sdk/explored.html#/sample/sap.ui.comp.tutorial.smartControls.04/preview

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Lukas Böhm Mar 19 at 03:38 PM
0

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" />
Share
10 |10000 characters needed characters left characters exceeded