cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying Tray dynamically

former_member184739
Contributor
0 Kudos

Hello experts

Please tell me how to expand or collapse a Tray dynamically via code

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member210804
Active Participant
0 Kudos

hi Prabhakaran,

follow the below application procedure,

I have created 2 attributes EXPAND1 and EXPAND2 with property wdy_boolean.

I created 2 trays( tray1 and tray2) and bind these attributes with EXPANDED property of tray UI element. shown below

For Tray1 , I have created onToggle event (ontoggle1) and

For Tray2, I have created onToggle event (ontoggle2) .

In WDDOINIT , I made both tray COLLAPSE by passing initial values to the attributes .

For ONTOGGLE1 action, follow the coding..

METHOD onactionontoggle1 .


   DATA lo_el_context TYPE REF TO if_wd_context_element.
   DATA ls_context TYPE wd_this->element_context.
   DATA lv_expand1 TYPE wd_this->element_context-expand1.
   DATA lv_expand2 TYPE wd_this->element_context-expand2.


*   get element via lead selection
   lo_el_context = wd_context->get_element( ).

*   get single attribute
   lo_el_context->get_attribute(
     EXPORTING
       name `EXPAND1`
     IMPORTING
       value = lv_expand1 ).

   IF lv_expand1 = 'X'.
     lv_expand1 = 'X'.
     lv_expand2 = ''.
   ELSE.
     lv_expand1 = ''.
     lv_expand2 = 'X'.

   ENDIF.

   CALL METHOD lo_el_context->set_attribute
     EXPORTING
       value = lv_expand1
       name  = 'EXPAND1'.

   CALL METHOD lo_el_context->set_attribute
     EXPORTING
       value = lv_expand2
       name  = 'EXPAND2'.


ENDMETHOD.

For ONTOGGLE2 , Follow the code..


METHOD onactionontoggle2 .

   DATA lo_el_context TYPE REF TO if_wd_context_element.
   DATA ls_context TYPE wd_this->element_context.
   DATA lv_expand1 TYPE wd_this->element_context-expand1.
   DATA lv_expand2 TYPE wd_this->element_context-expand2.


*   get element via lead selection
   lo_el_context = wd_context->get_element( ).

*   get single attribute
   lo_el_context->get_attribute(
     EXPORTING
       name `EXPAND2`
     IMPORTING
       value = lv_expand2 ).

   IF lv_expand2 = 'X'.
     lv_expand1 = ' '.
     lv_expand2 = 'X'.
   ELSE.
     lv_expand1 = 'X'.
     lv_expand2 = ' '.

   ENDIF.

   CALL METHOD lo_el_context->set_attribute
     EXPORTING
       value = lv_expand1
       name  = 'EXPAND1'.
   CALL METHOD lo_el_context->set_attribute
     EXPORTING
       value = lv_expand2
       name  = 'EXPAND2'.


ENDMETHOD.

Once You follow the above steps....result will be shown like below screenshots.


If you click on Block2 ,

If You click on Block3,

Best regards,

Narasimha Rao Putturi.

former_member210804
Active Participant
0 Kudos

HI

Please close the thread...if u solve your problem

Answers (1)

Answers (1)

Former Member
0 Kudos

   Hi Prabaharan,

       In tray you will get a propery called 'expanded'. Take a context attribute of type 'WDY_BOOLEAN' & bind this property with this attribute. Then you can set the value of this attribute from your program & set collapse & expand behaiviour of the tray by coding.

Regards,

Monishankar Chatterjee

former_member184739
Contributor
0 Kudos

Hi shankar

Can you please provide me sample code? I have already binded the wdy_boolean to expandable property.

Now as my selection screen is large I ve divided into three blocks. Second block and third block are in a tray. Now when choosing(collapsing. )second tray ,third one must expand and when expanding second tray ,third tray must collapse. I am doing this to reduce the complexity of selection screen

Please advise

Thanks

Former Member
0 Kudos

Hi Prabaharan,

" Second block and third block are in a tray. Now when choosing(collapsing. )second tray ,third one must expand and when expanding second tray ,third tray must collapse"

     

      You have already created the attributes. Here you have two tray so you need two attribute.

    1.   Now bind it with the property.    

    2.   Decide first time both will be collaped state . any one will be expanbded. based on this you may

          provide any default value to the attribute. 

    3.  identify the actions where you need expand & collaps the trays. Here u can use the 'On Toggle'

         action for a tray. When ever you expand / collapse the tray , thisa caion triggers.

         So your approach will be like --

         a. For the 'On Toggle ' action of the first tray check the first attribute value and set the 2nd

            according to that ( i.e. if att1 = 'X' then att2 = ' '  .      )

         b. follow the same process for the 2nd "On Toggle' .

   Chekc the reply of Narasimha, a good explanatory one.

Regards,

Monishankar Chatterjee