Skip to Content
avatar image
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 comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • 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 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.