on 11-17-2009 6:40 PM
Hi All,
I have a drop down by key element in the view, I have binded the value to it.
But when i run my application the drop down is not showing the key's instead the values are displayed.
In WDDOINIT I have the following code.
DATA: lf_value_set type wdy_key_value.
DATA: lt_value_set type wdy_key_value_table.
lf_value_set-key = lf_tzone-zone. " Key
lf_Value_set-value = lf_tzone-descript. " Description
INSERT lf_value_set INTO TABLE lt_value_set.
Added to the attribute info
lo_nd_info = lo_nd_termination_details->get_node_info( ).
lo_nd_info->set_attribute_value_set( name = 'TZONE' value_set = lt_value_set ).
To Display the keys along with the values in Drop down I have coded the following in WDMODIFYVIEW
DATA: lcl_tzone type ref to cl_wd_dropdown_by_key.
Change the dynamic properties of dropdown box
lcl_tzone ?= view->get_element( 'TZONE_DDL').
Key visible
lcl_tzone->SET_KEY_VISIBLE( abap_true ).
Till this point everything works fine.
My requirement is when i select any of the values in dropdown i need to display the KEY as the selected one instead of VALUE. Can you please help me how can i achieve this.
Thanks,
Krishna
Hi Krishna,
To do this have the values of
key = KEY
value = KEY.
This will have a dropdown of keys. when you select also the Key will be displayed.
Regards,
Shalini.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello All,
Thanks for your Response.
But my requirement is to display KEY and VALUE in the drop down (Set_key_visible->abap_true)
Eg:
RED 01
BLUE 02
GREEN 03
on selection both the key+value should be displayed as selected one.
Eg: RED 01.
To over come this I did it other way round.
VALUE_SET-KEY = 'KEY'.
CONCATENATE KEY VALUE INTO VALUE_SET-VALUE SEPARATED BY SPACE.
Thanks once again for all your help..
Regards,
Krishna
hi,
Drop down by key will be used to map simple types created in dictionary . This simple type will have Key and the value. The value will be displayed in the drop down and by selecting it, we can get the corresponding key.
if u r using drop down by key , than proceed like this :
1 declare a context node of cardinality 0..1
2 declare attribute of type string under it . The attribute name should be exactly the same as that in database table '
eg if u want to poulate values for a field ' SYS' from table , than giv the attribute name as 'SYS' in context attribute
3 declare internal table of type standard table
4 populate internal table with values
5 take the refernce of the node , u have created
6 bind it with the internal table
here is one code as an example for ur reference
TYPES: BEGIN OF str_roles,
-> role TYPE z0cz_roles-role_id,
-> END OF str_roles.
->DATA: it_role TYPE TABLE OF str_roles,
-> wa_role TYPE str_roles.
->DATA: value1 TYPE wdy_key_value,
-> set TYPE wdy_key_value_table.
-> SELECT role_id FROM z0cz_roles INTO TABLE it_role.
->SORT IT_ROLE DESCENDING BY ROLE.
-> LOOP AT it_role INTO wa_role.
-> value1-key = sy-tabix.
-> value1-value = wa_role-role.
-> APPEND value1 TO set.
-> ENDLOOP.
-> DATA : node_info TYPE REF TO if_wd_context_node_info.
-> node_info = wd_context->get_node_info( ).
-> node_info = node_info->get_child_node('CN_DROPDOWN').
->node_info->set_attribute_value_set( name = 'CA_ROLE' value_set = set ).
regards,
amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.