Hi All,
while developing the custom free-style UI5 app with OData v2, I’m using SAP smart controls to save some development time, and I have some examples to share.
PresentationVariant Annotation
- Defines the visualizations and sort order for the UI presentation.
- Visualizations are defined using UI.LineItem annotation.
- Sort order is based on the given field property in descending order.
- Note: under my experience, if you use ResponsiveTable type, then the sorter can not be applied by annotation.
<Annotations Target="your_srv.entity_type">
<Annotation Term="com.sap.vocabularies.UI.v1.PresentationVariant">
<Record>
<PropertyValue Property="Visualizations">
<Collection>
<AnnotationPath>@UI.LineItem</AnnotationPath>
</Collection>
</PropertyValue>
<PropertyValue Property="SortOrder">
<Collection>
<Record Type="Common.SortOrderType">
<PropertyValue Property="Property" PropertyPath="field1" />
<PropertyValue Property="Descending" Bool="true"/>
</Record>
</Collection>
<Collection>
<Record Type="Common.SortOrderType">
<PropertyValue Property="Property" PropertyPath="field2" />
<PropertyValue Property="Descending" Bool="true"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>FilterRestrictions Annotation:
- Specifies the filter restrictions for the entity type.
- Requires filters to be applied and lists properties with filter expression restrictions.
- In this example, both field1 and field2 are set as mandatory filters, and only a single value is allowed.
<Annotations Target="your_srv.your_srv_Entities/EntitySet">
<Annotation Term="Org.OData.Capabilities.V1.FilterRestrictions">
<Record Type="Capabilities.FilterRestrictionsType">
<PropertyValue Property="RequiresFilter" Bool="true"/>
<PropertyValue Property="RequiredProperties">
<Collection>
<PropertyPath>field1</PropertyPath>
<PropertyPath>field2</PropertyPath>
</Collection>
</PropertyValue>
<PropertyValue Property="FilterExpressionRestrictions">
<Collection>
<Record Type="Capabilities.FilterExpressionRestrictionType">
<PropertyValue Property="Property" PropertyPath="field1"/>
<PropertyValue Property="AllowedExpressions" String="SingleValue"/>
</Record>
<Record Type="Capabilities.FilterExpressionRestrictionType">
<PropertyValue Property="Property" PropertyPath="field2"/>
<PropertyValue Property="AllowedExpressions" String="SingleValue"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>Common.FieldControl:
- Hides certain fields or properties based on field control type.
- Used to hide fields like field1.
<Annotations Target="your_srv.EntityType/field1">
<Annotation Term="com.sap.vocabularies.Common.v1.FieldControl" EnumMember="com.sap.vocabularies.Common.v1.FieldControlType/Hidden"/>
</Annotations>You can also use this annotation to field binded Value List.
Common.Text and UI.TextArrangement Annotations:
- Specifies the text arrangement.
- Defines whether text should be displayed first, last, or only.
- Example see below value list annotation.
<Annotations Target="your_srv.EntityType/field1">
<Annotation Term="Common.Text" Path="field1_name">
<Annotation Term="UI.TextArrangement" EnumMember="UI.TextArrangementType/TextFirst"/></Annotation>
<Annotation Term="Common.ValueList">
<Record>
<PropertyValue Property="Label" String="{i18n>Field1}"/>
<PropertyValue Property="CollectionPath" String="ZEXAMPLE_VH"/>
<PropertyValue Bool="true" Property="SearchSupported"/>
<PropertyValue Property="Parameters">
<Collection>
<Record Type="Common.ValueListParameterOut">
<PropertyValue Property="LocalDataProperty" PropertyPath="field1"/>
<PropertyValue Property="ValueListProperty" String="ValueList_field1"/>
</Record>
<Record Type="Common.ValueListParameterDisplayOnly">
<PropertyValue Property="ValueListProperty" String="ValueList_field1_name" />
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
UI.HiddenFilter Annotation:
- Hides certain filters in the mentioned entity in Target attribute.
- this can be implemented in both your data entity (hide in smartFilters) or value help entity(hide in value help dialog).
<Annotations Target="your_srv.EntityType/field1">
<Annotation Term="UI.HiddenFilter" Bool="true"/>
</Annotations>
You can also find some local annotation examples in this blog by Chandra: https://community.sap.com/t5/technology-blog-posts-by-members/some-of-ui-annotations-local-annotatio...
I hope my examples are clear and can save some of your development time.
Thanks,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.