Skip to Content

SmartFilterBar - Default values using Annotations not working

Hi Team,

I am using SmartFilterBar control to display the selection fields using the annotations and it is working correctly. I would like to default values for one of the selections fields. I found sample example which does the same thing and populates selection fields Company Code as an example. I defined Location entity type entity-type.jpg which has property "RangeId". Initialization of the property is done using annotations.jpg. Selection screen is displayed correctly but default value not shown. Also checked console and there are no errors. Please provide the solution or direct me in the right direction.

Note: I tried downloading sample example into web ide and and it doesn't work there. It appears to be I am missing something.



entity-type.jpg (123.9 kB)
annotations.jpg (43.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Feb 20, 2019 at 07:50 PM

    Hello @Yellappa Madigonde (or anyone having this issue)

    I had this same issue today.

    The root cause is that this feature is only available since 1.48.0 and in my case I'm using 1.44.7.

    In my scenario, I had to enter the low and high values of a date range inside the smartfilterbar.

    I tried to create a polyfill using 1.48.0 code but the effort is insane so I did the trick inside my Controller (I believe something similar could be achieved when using Fiori Elements, which is not my scenario).

    	_setDefaultDate: function (oEvent) {
    			 * Unfortunately, annotation SelectionVariant is not handled in UI5 1.44.x
    			 * As a result, it's not possible to set a default value for the date range field using annotations.
    			 * This function is a workaround that sets the default value for the date range.
    			 * When upgrading to 1.48.x or later version of UI5, please use SelectionVariant annotation 
    			 * as commented in the 'annotation.xml' file.
    			var oSelectionSet = this._oSmartFilterBar._retrieveCurrentSelectionSet(false, true);
    			var oFilterColumns = {
    				DATE_RANGE: "DateRange" // Property linked with the DateRange field in the smartfilterbar
    			for (var i = 0; i < oSelectionSet.length; i++) {
    				var oControl = oSelectionSet[i];
    				var sId = oControl.getId();
    				if ( >= 0) {
    					var oDataRange = oControl;
    					var dLowDate = new Date();
    					var dHighDate = new Date();
    					dHighDate.setDate(dHighDate.getDate() + 14); // 2 weeks
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.