cancel
Showing results for 
Search instead for 
Did you mean: 

Web dynpro UI element visibility

Former Member
0 Kudos

Hi

My situation is this.

I have a view on which I want to display certain fields to the user depending on whether a particular value is present in a database table.

In the Context I have attributes of type WDUI_VISIBILITY which are mapped to the relevant UI elements in the layout that I want to set to visible or not when the view loads.

In the WDDOINIT method I have declared local variables like so: DATA lv_visible TYPE wd_this->element_properties-visible.


I then perform the database check which I can see is fine in debugging and assign values to my local variables:



IF lv_unfal NE 'X'.
       lv_visible = 02.
      lv_hod_visible = 01.

     ELSE.
       lv_visible = 01.
      lv_hod_visible = 02.


And then assign those values to the context element.



     lo_el_properties->set_attribute( name = 'VISIBLE' value = lv_visible ).
    lo_el_properties->set_attribute( name = 'HOD_VISIBLE' value = lv_hod_visible ).
    lo_el_properties->set_attribute( name = 'HOD' value = lv_hod_vis ).


However on loading the view not all of the UI elements are being made visible/invisible as I would expect/hope! I am missing something here? I've used this concept before and it worked ok. Is is something to do with the WDDOINIT method?


As always very grateful for any suggestions.


Thanks

Jon



Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All.

Problem sorted!

I inherited this project from another developer and in the layout he had used nested containers. Each container was having the visible property set either with the visible value or from a context attribute. Consequently this was effecting the visibility of the elements within the container when I was tring to set them with whichever method.

Thanks for all of your suggestions.

Jon.

Answers (3)

Answers (3)

Gowtham
Contributor
0 Kudos

Hi Jon,

  • Make sure you binded the visibility attribute to all required UI element's Visible Property.
  • Make sure any other methods like modifyview or some other is not overwriting this visibility value.

- Gowtham

Former Member
0 Kudos

Hi Gowtham

I've double checked all the assignments and I have bound the visibility attribute to all required UI element's Visible Property.

There are no other methods with code that is overwriting the INIT method. One of the elements involved is a checkbox which has an onToggle event. I'm not interacting or setting it on loading the view but might that have an effect?

Cheers

Jon.

Former Member
0 Kudos

Hi,

You havent assigned any value to lv_hod_vis as per the code provided by you. Try to assign value and check.

Hope this helps you to resolve your issue.

Thanks

KH

Former Member
0 Kudos

Hi Katrice

lv_hod_vis is being assigned a value I just didn't include it in the code snippets that I posted.

Cheers

Jon.

Former Member
0 Kudos

Hi,

Is there any code in WDMODIFYVIEW( )  ??

Thanks

KH

Former Member
0 Kudos

Hi,

Is there any code in WDMODIFYVIEW( )  ??

Thanks

KH

Former Member
0 Kudos

Hey,

Nothing in WDDOMODIFYVIEW!

ramakrishnappa
Active Contributor
0 Kudos

Hi Jon,

When you bind the visibility property of ui element to attribute in context menu. By default the ui elements are not visible. So we need to set it based on the requirement, either in wddoinit or on action.

Make sure that the visibility property of the ui elements which you suspect are not working as per your expectation are bound to the attributes VISIBLE OR HOD_VISIBLE.

By any chance bound to any other attribute.

Regards,

Rama

Former Member
0 Kudos

Hi Rama

Can you elaborate on how by default the the ui elements are not visible please?

I've double checked all the assignments and I have bound the visibility attribute to all required UI element's Visible Property.

There are no other methods with code that is overwriting the INIT method. One of the elements involved is a checkbox which has an onToggle event. I'm not interacting or setting it on loading the view but might that have an effect?

Cheers

Jon