on 03-11-2013 5:49 PM
Hello experts
Please tell me how to expand or collapse a Tray dynamically via code
Thanks
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.