on 2020 Mar 23 7:21 PM
Does anyone know how to dynamically set the @UI.Hidden annotation using CDS Annotations? I can do it with XML Annotations (<Annotation Term="UI.Hidden" Path="anXfeld">) and it works perfectly. Can't figure out how to do it with CDS. Seems @UI.Hidden can't use a path?
<Annotations Target="Metadata.xDSNxC_CM_CONTType">
<Annotation Term="UI.FieldGroup" Qualifier="cont_checkboxes">
<Record Type="UI.FieldGroupType">
<PropertyValue Property="Data">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="fundingcontrol"/>
<PropertyValue Property="Label" String="Funding Control"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="extfundingsource"/>
<PropertyValue Property="Label" String="Ext Funding"/>
<Annotation Term="UI.Hidden" Path="fundingcontrol"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
Request clarification before answering.
I figured this out by reverse engineering the generated XML annotations and comparing them to XML that I knew worked.
for somereason adding @UI.hidden: #(fieldname) didn't work putting it directly on the field. I had to add it to the fieldgroup annotation i.e.
@UI.fieldGroup: [{ label: 'Funding Control',
qualifier: 'cont_checkboxes',
position: 130,
hidden: #(modcontrol) }]
fundingcontrol;
This will hide fundingcontrol if modcontrol is checked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for sharing, Paul. It's some hidden/unreleased feature i guess 🙂
Such a simple and helpful solution.
Totally worked for me !
Thanks.
Hi Paul,
Thank you very much for this post.
I would like to add that "modcontrol" must be of type boolean.
I first tried it with
virtual HideLink : abap.char( 1 ),
but this did not work.
Only after having changed the definition of my virtual field to
virtual HideLink : abap_boolean,
the field (that contains a URL) was hidden.
Hi Andre Fischer,
do you know what the reason is that this is not done via the instance features of RAP, like read only etc.?
I find this rather impractical/unattractive that in the worst case I need a virtual element for each field which I want to hide, when they have different conditions.
Thanks in advance, Florian
Hey Florian,
did you found an answer for your question? I'm also curious why I can't use the dynamic feature control for hiding fields. It is really impractical to implement field control with SADL/virtual elements to hide fields and to implement the dynamic feature control for make fields read-only or mandatory. We have over 100 fields.
Did you get it working with virtual elements to hide a column in a table inside an ObjectPage? I didn't find any solution so far for this problem. It is only working for me to hide field inside the object page.
Thanks & Cheers
Andreas
Hey Paul,
I tried to implement your solution but with no luck.. I don't know what it was that I didn't see..
Hopefully this alternative worked! Hope it helps!
Cheers,
George
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That seems like a lot of work for a simple thing. Think something not obvious must have been going on.
What you describe in your blog is exactly what the framework does under the hood when you mark a field as 'EXTERNAL_CALCULATION' (Though I see there was a technical reason you couldn't do that).
If you have
@ObjectModel.enabled:'EXTERNAL_CALCULATION'
somefield,
on your odata service a new field will be created called "somefield_fc" and "somefield" will use "somefield_fc" as it's field control. (Note, if you're using SEGW project as opposed to @Odata.publsh:true you MUST regenrate your project after marking any field as EXTERNAL_CALCULATIOn or the new *_fc field wont be available)
<Property Name="modnumber" Type="Edm.String" MaxLength="35" sap:display-format="UpperCase" sap:field-control="modnumber_fc" sap:label="Modification Number" sap:quickinfo="Mod Number"/>
The @UI.hidden:#(someval) does work and is very lightly documented.
But, at the end of the day, it just translates to the XML annotation "<Annotation Term="UI.Hidden" Path="hidemod"/>" which is also another way to accomplish this in a local annotation file.
<Record Type="UI.DataField"><PropertyValue Property="Label" String="Authorized Unplanned Vaue"/><PropertyValue Property="Value" Path="authunvalue"/><Annotation Term="UI.Hidden" Path="hidemod"/></Record>
I use My Inbox in a few place, I might see if I can make it work and report back.
Can u try this and check.
Use EXTERNAL_CALCULATION and use annotation readOnly.
But in the determination, call property helper method "set_attribute_enabled".
Thanks,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're using the CAP framework, it should look like this:
Note that it will only accept a boolean field.
FieldGroup #General : {Data : [
{
Value : AUART,
Label : '{i18n>AUART}'
},
{
Value : VKORG,
Label : '{i18n>VKORG}',
![@UI.Hidden] : IsActiveEntity
},
{
Value : VTWEG,
Label : '{i18n>VTWEG}'
},
{
Value : SPART,
Label : '{i18n>SPART}'
}
]},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
11 | |
9 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.