cancel
Showing results for 
Search instead for 
Did you mean: 

How to hide a label in webdynpro

Former Member
0 Kudos

Hi.

I have a Label and a dropdown in the window, where on selecting the particular value in my previous dropdown. This label and drop down need to be visible. How to hide the field.

Kindly help me to solve this one.

Thanks

Yogesh

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Thanks for your messages, i have used the variable in the ui element and the setting the value to the variable resolved my problems.

Thanks

Yogesh

Former Member
0 Kudos

Hi,

Thanks for your reply.

I am using the label in the on the select event only. Which i am able to hide, now i need to display it again.

it would be greatful, if you could reply with some coding.

Thanks

Yogesh

Former Member
0 Kudos

hi,

set the visibility to 02 , like this.

IF NOT lo_label INITIAL.

lo_label->set_visible(value = 02 ).

ENDIF.

This will make the lable visible.

Cheers,

Aditya.

Former Member
0 Kudos

There is a property Visible in both Lable and Dropdown UI elements. create a context attribute of type WDUI_VISIBILITY and bind it with this property.

Set the value if this attribute as you wish. Hope it helps.

Former Member
0 Kudos

Hi,

You can use the ONSELECT event of the previous dropdown (the dropdown whose value you want to use to make the label invisible).

In the evenhandler for ONSELECT event has paramaters like CONTEXT_ELEMENT , ID and KEY where ID is the ID of dropdown

and KEY is the value selected in dropdown.

EXAMPLE,

DATA : lo_label = cl_wd_label.

IF key EQ 'I agree'.

lo_label ?= view_instance->get_element(ID = 'LABEL_ID').

IF NOT lo_label INITIAL.

lo_label->set_visible(value = 01 ).

ENDIF.

ENDIF.

The view_instance has to be set with value of attribute"view" in ur WDMODIFY method of view.

Similarily you can make dropdown or any UI element invisible.

Hope it helps.

Thanks,

Aditya.

ChrisPaine
Active Contributor
0 Kudos

Accessing the view outside of the WDDOMODIFYVIEW method is not recommended coding practice.

Rather, it is better practice to have context attributes which are bound to the visibility properties of the UI element. You can then update these context attributes directly in the action handlers.

Also, on the topic of good coding practice, you should use some of the standard constants to define visibility - not just hard code values in your code. Use CL_WD_UIELEMENT=>E_VISIBLE-NONE, CL_WD_UIELEMENT=>E_VISIBLE-VISIBLE, or CL_WD_UIELEMENT=>E_VISIBLE-BLANK.

Use context bindings to control your layout if you can - that's what they are there for - it makes your code easier to understand and to follow. Updates using dynamic coding are hard to find in code and can be very confusing. Directly accessing the view should be a last resort, and only then within the WDDOMODIFYVIEW method.

My thoughts,

Chris

Former Member
0 Kudos

Hi,

You can use the attribute 'Visible' for both the label and the dropdown. You can bind them to a variable in your context to dynamically make them visble. If you enter an event in your first dropdown and switch your variable in the context depending on the input in the corresponding event handler you can have the visibility depend on the value in the first dropdown.

Regards,

Sjoerd.