Skip to Content
author's profile photo Former Member
Former Member

Change Visibility of an UI Element at runtime.

Hi Experts,

I have an UI element "Explanation" on my web dynpro View. I want to make it visible or invisible at run time by using some events. To access its visible property I have created an attribute of type "WDUI_VISIBILITY" and given it the default value '02' for visible. I have assigned it to the UI element as its visible property value. Now I want to make the field invisible at run time by changing the attribute's value to '01'(for invisible). But the problem is that when i run the application the UI element is not visible however I have given it the value '02' by default. Please suggest what to do.

Thanks and Regards,

Vaibhav Tiwari.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Sep 23, 2008 at 05:15 AM

    Hi Vaibhav,

    I guess that you have not set the "help mode" to on. You will have to set this property so that you can display the explanation UI element. You can do it in 2 ways:

    1) Using the personal settings in the portal

    2) Or in the URL associated with the component you can set the parameter "sap-explanation" to "X"

    ex:

    http://ctsgvcsap3.cts.com:8000/sap/bc/webdynpro/sap/z187442_temp?sap-client=251&sap-language=EN&sap-explanation=X

    If you have a pushbutton and want to toggle the explanation visibility state between visible & invisible you can do it as follows: (I have bound the explanation ui element to an attribute named VISIBILITY of type WDUI_VISIBILITY and has a default value of 2)

    METHOD onactionontoggle .
      DATA lo_nd_exp TYPE REF TO if_wd_context_node.
      DATA lo_el_exp TYPE REF TO if_wd_context_element.
      DATA ls_exp TYPE wd_this->element_exp.
      DATA lv_visibility LIKE ls_exp-visibility.
    *   navigate from <CONTEXT> to <EXP> via lead selection
      lo_nd_exp = wd_context->get_child_node( name = wd_this->wdctx_exp ).
    
    *   get element via lead selection
      lo_el_exp = lo_nd_exp->get_element(  ).
    
    *   get single attribute
      lo_el_exp->get_attribute(
        EXPORTING
          name =  `VISIBILITY`
        IMPORTING
          value = lv_visibility ).
      IF lv_visibility = '02'.
        lo_el_exp->set_attribute(
        EXPORTING
          name =  `VISIBILITY`
          value = '01' ).
      ELSE.
        lo_el_exp->set_attribute(
          EXPORTING
            name =  `VISIBILITY`
            value = '02' ).
      ENDIF.
    ENDMETHOD.

    Hope this helps you sort out your problem.

    Regards,

    Uday

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Uday,

      The problem is resolved. The problem was just that I set the UI element property to 'none' first after that i assigned it the attribute value. When I changed its visible property value to 'visible' and then assigned the attribute in its property its working fine. It should not behave like this but it may be some problem with the SAP system.

      Regards,

      Vaibhav Tiwari.

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.