cancel
Showing results for 
Search instead for 
Did you mean: 

Hide Facet conditionally in fiori elemetns

mhappe
Participant
0 Kudos
5,378

Hello,


Does somebody know, it's possible to hide a UI Facet (in my case a reference facet to a table) conditionally?

In some circumstances I need to hide a reference facet of a table of a child element.

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert

Hi Mattjs

It certainly must be possible because that's one of the things we do with UI Adaptation at runtime!

What you want to think about is perhaps @UI.hidden and providing a value for true/false dynamically. That's easy to do if you are providing the value via a metadata extension to a CDS view.. i.e. use a virtual attribute of the CDS view to calculate your true/false boolean and pass that as the value of @UI.hidden

Rgds

Jocelyn

mhappe
Participant

Hi Jocelyn,

Thanks for your quick response. Yesterday i tried to set the facet to hidden using the @UI.hidden annotation, but the annotation wasn't taken into account by the UI.

Today I tried it again, but using a higher UI5 version in my run configuration in WebIde. Now the facet was hidden 🙂 So the annotation UI.hidden on a facet doesn't get reflected in older UI versions (1.48 and lower).

bernd_steinhauer
Explorer
0 Kudos

Hello Jocelyn,

you mentioned above, that in metadata extensions for CDS-Views it is possible to provide values dynamically instead of String literals. Could you please give me a small example, showing the syntax?

Best Regards

Bernd

Answers (4)

Answers (4)

GManousaridis
Participant

Hey everyone,

Unfortunately, I was not able to implement the metadata extension, because I was working on an extend view and the original view doesn't allow metadata extensions.

But a code based alternative approach is possible. You can find it in this blog.

Cheers,

George

lavanyar087
Associate
Associate
0 Kudos

Hi Mattijs,

can you please tell me what did you provide in the value for UI.hidden? I have a very similar requirement. I want to hide a section during creation mode alone. I would prefer to do it in metadata extension of CDS.

Regards,

Lavanya

mhappe
Participant
0 Kudos

Hi Lavanya,

I added annotations using the annotation modeler as the version of our backend system doesn't support ui.facet annotation in cds view.

In our case the value of hidden was bound to an attribute of the entity.

In our UI5 version, the value false set the facet to hidden and viceversa.

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Good tip! Mattjs. If you are interested in sharing your experiences, it would make a good blog that we could add to the Fiori elements wiki https://wiki.scn.sap.com/wiki/display/Fiori/Fiori+elements

I'd be happy to add it in if you can do a short blog on this?

0 Kudos

Hi Jocelyn,

I have same requirement, to hide the facet dynamically. I have tried with using virtual attribute in metadata extension and in consumption cds view.

But Its not working.

Please could you share the step and simple code. Then It would be very helpful.

Thanks in advanced!

Regards,

Dhiraj

ArneVH
Explorer
0 Kudos

@ui.hidden can be filled with a dynamic value as follows:  @ui.hidden: #(<boolean_fieldname_in_cds>)

So a hashtag, open braket, fill in your field name that is dynamic (ie a virtual element, or just another field from your data-source...) close braket.

The field that is mentioned must, of course, be a boolean!
Hope this helps anyone looking for the concrete code to get this working.