on 08-02-2007 1:10 PM
Hi,
Can any body tell me,how to get the selected value in the dropdown listbox.
I filled the value in the dropdown listbox,all the value avl in the dropdown listbox,but i can't able get the selected value in the dropdown list box.
can anybody tell me what may the problem.
thanks in advance,
Regards,
Ravi
Hi Ravi,
As I can see from the snippets you have posted, you are using a DropDownByKey and not a DropDownByIndex. To get the selected value in the OnSelect event, use the following code -
lo_el_country = wdevent->get_context_element( name 'COUNTRY' ).
lo_el_country->get_attribute(
exporting
name = 'LAND1'
importing
value = lv_land1 ).
The parameter wdevent is available as an importing parameter to the action handler (So you don't have to declare it).
Regards,
Neha
<i><b>PS:Reward if helpful</b></i>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi ravi.........
you just click the code wizard button and read the attribute to which the dropdown box has been bound. with this you can get the current value. in case if you want to get other values, you can get it by index.
-
regards,
alex b justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
i did the same thing,kindly check the follwing code.
In Do-init,
data: lt_valueset type standard table of wdr_context_attr_value,
ls_valueset type wdr_context_attr_value,
lr_node_info type ref to if_wd_context_node_info,
lr_node type ref to if_wd_context_node,
wa_T005U type T005U,
lt_T005U like table of wa_T005U.
lr_node = wd_context->get_child_node( 'COUNTRY' ).
lr_node_info = lr_node->get_node_info( ).
select distinct land1 from T005U into table lt_T005U.
loop at lt_T005U into wa_T005U.
ls_valueset-value = wa_T005U-land1. "this will be the selected value
ls_valueset-text = wa_T005U. "this will be the displayed value in the UI
append ls_valueset to lt_valueset.
endloop.
lr_node_info->set_attribute_value_set(
exporting
name = 'LAND1'
value_set = lt_valueset ).
I filled the dropdown list box,with the help of above code and also read the attribute land1 value into my selectkey in the layout.
In dropdown list all the values are displaying,i can't able to select the 2nd,3rd value... in the drop down list apart from the default(1st) value.
Thanks in advance,
Regards,
Ravi.
hi ravi.............
i hope you will be having youe attribute to which the dropdown box has been bound, inside a node. consider the node name to be 'a'.
when you click that node, its properties will be displayed below.
in that there will be an option called 'supply function'.
just enter any name for that function. it automatically creates a method of the same name.
now you write the same codings just like you have written in the initialization, inside that method.
so whenever you invalidate the node 'a' or initialized, this supply function would be called.
now go to the method of the 'onaction' of dropdown box and write the codings to read the attribute. now it will work perfectly..
---regards,
alex b justin
Hi Ravi,
Your code is fine. If the selectedKey property is bound to the context attribute, it should work fine. What is the code in your onSelect event? You should simply do get_element and read the static attributes, and it will give you the selected value. Please post the code in your onSelect event.
Regards
Nithya
hi nithya,
This is my code in the "onSelect" event.
data:
Node_Country type ref to If_Wd_Context_Node,
Elem_Country type ref to If_Wd_Context_Element,
Stru_Country type If_Main=>Element_Country,
wa_T005U type T005U,
lt_T005U type table of T005U.
.
navigate from <CONTEXT> to <COUNTRY> via lead selection
Node_Country = wd_Context->get_Child_Node( Name = IF_MAIN=>wdctx_Country ).
get element via lead selection
Elem_Country = Node_Country->get_Element( ).
get all declared attributes
Elem_Country->get_Static_Attributes(
importing
Static_Attributes = Stru_Country ).
select * from T005U into table lt_T005U where land1 = Stru_Country-land1.
Node_Country = wd_context->get_child_node( Name = 'COUNTRY' ).
Node_Country->bind_table( lt_T005U ).
i think i did every thing correct,eventhough i didn't get the selected value in my dropdown list box.
kindly give your suggestion.
Thanks in advance,
Regards,
Ravi.
hi ,
Your code looks fine and you need to use supply fuction you can put your code in wddoinit method itself.
loop at lt_T005U into wa_T005U.
ls_valueset-value = wa_T005U-land1. "this will be the selected value
ls_valueset-text = wa_T005U."this will be the displayed value in the UI
append ls_valueset to lt_valueset.
endloop.
here why you are not passing value to text filed.
this may be the reason or just sort it and pass it to set_attribute_value_set.
or make sure your UI element type is DROPDOWN_BY_KEY.
regards
sarath
Hi Ravi.
use the wizard button in the code where you want to access the attribute.
Regards
Abhimanyu L
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.