on 2023 Apr 21 4:57 PM
Hi experts,
i am currently developing a SAPUI5 application based on oData service with some annotations.
I have implemented a smart filter table to manage filters within my app. These filters are automatically handled by the annotation on odata metadata.
Everything works fine.
In these input parameters I have a string type field where I am correctly able to open the panel to manage the values to be filtered:
My question is the following: is it possible to manage the conditions within the menu? For example being able to select only the "equal" and "not equal to" options without seeing the others
Regards,
Alessandro.
Request clarification before answering.
Hi Alessandro,
The drop down list will contain filter operators based on the base type property of the field (Date, Integer, String etc). You might explore the "AllowedExpressions
" property to reach you goal.
Reference :https://sapui5.hana.ondemand.com/sdk/#/topic/a5608eabcc184aee99e1a7d88b28816c.html
I am not sure if the app is total annotations driven or custom one, but in the latter case, you might be able to write a custom code to fetch the list and remove the non-required values.
Thanks
Shobhit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alessandro,
You can use the Filter Expression Restrictions annotations to customize the Define Conditions dropdown inside a VH. It will be customized according to the restrictions you define in the annotation, you can also specify the max. no. of conditions that can be defined.
Something like this should work for local annotations.
<Annotations xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="Org.OData.Core.V1.FilterExpressionRestrictions">
<Record>
<PropertyValue Property="AllowedExpressions">
<Collection>
<String>com.sap.vocabularies.UI.v1.OperationAvailable</String>
<String>com.sap.vocabularies.UI.v1.FilterExpression</String>
<String>com.sap.vocabularies.UI.v1.ValueList</String>
<String>com.sap.vocabularies.UI.v1.TextFilterRestriction</String>
</Collection>
</PropertyValue>
<PropertyValue Property="Expression" String="com.sap.vocabularies.UI.v1.FilterExpression" />
<PropertyValue Property="FilterExpression">
<Record>
<PropertyValue Property="Value" String="com.sap.vocabularies.UI.v1.Contains" />
</Record>
</PropertyValue>
<PropertyValue Property="MaxLength" Int="1" />
</Record>
</Annotation>
</Annotations>
AllowedExpressions
: Specifies the allowed expressions for filtering, in this case, com.sap.vocabularies.UI.v1.OperationAvailable
, com.sap.vocabularies.UI.v1.FilterExpression
, com.sap.vocabularies.UI.v1.ValueList
, and com.sap.vocabularies.UI.v1.TextFilterRestriction
.Expression
: Specifies the default expression to be used for filtering, in this case, com.sap.vocabularies.UI.v1.FilterExpression
.FilterExpression
: Specifies the filter expression to be used, in this case, com.sap.vocabularies.UI.v1.Contains
, which represents the 'contains' operator.MaxLength
: Specifies the maximum length of the allowed filter expressions, in this case, 1
.You can find more about the Annotations here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leoni,
thanks for the response.
I have the following code in my CAP application
annotate MyEntity with @( UI: { SelectionFields: [UserId], } );How can i implement your suggestion?
I looked for the references to the suggested annotations but unfortunately I didn't find anything.
Thanks in advance
User | Count |
---|---|
79 | |
29 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.