cancel
Showing results for 
Search instead for 
Did you mean: 

how to find index of Selected entry from Item list box

Former Member
0 Kudos

Hi Experts,

I have item list box with 14 entries. Now on click of one button I want to add selected entry to one table. The problem is I am not able to find the selected entry from a node.

Kindly help me ..its urgent.....Points will be rewarded.

Thnaks in advance!!!

Cheers,

Darshna.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Harish ,

I am able to <b>find index of entry that is selected in Item list box in OnLead select</b> method as I have <b>checked UI parameter passing che</b>ckbox .

Now what I want do is to read <b>same index in my On_add</b> method. Please guide how to read Current entry selected in list box anywhere in program .

I know I can add that seleced entry to context but I dont want to do that .

solution will be rewarded .

Cheers

Darshna ,

Former Member
0 Kudos

If you don't want to add the selected entry to the context then take an atrrubute in the view or component controller. Just put the selected entry infromation in that attribute and do the remaining logic. if suppose you want to add all the selected entries the take the attrubute type as table.

Best Regads,

Vijay

Former Member
0 Kudos

Okay what you need to do is the following

assume you have got the index of the selected element in the event handler onLeadSelect which might look like this.

lo_nd_item_list = wd_context->get_child_node( name = wd_this->wdctx_item_list ).

lo_el_item_list = lo_nd_item_list->get_element( ).

data: lead type i.

CALL METHOD lo_nd_item_list->GET_LEAD_SELECTION_INDEX

RECEIVING

INDEX = lead

.

Now you either store this lead index in the assistance class or as a controller attribute or in the context. For simplicity what I have done is I have stored the value of the item at lead selection in a controller attribute

lo_nd_item_list = wd_context->get_child_node( name = wd_this->wdctx_item_list ).

lo_el_item_list = lo_nd_item_list->get_element( ).

lo_el_item_list = lo_nd_item_list->get_element( index = lead ).

lo_el_item_list->get_attribute(

EXPORTING

name = `ITEM_TEXT`

IMPORTING

value = lv_item_text ).

wd_This->SELELECTED_ELEMENT = lv_item_text.

as you might have guessed SELELECTED_ELEMENT is a controller attribute.

Now in the button's event handler I push this into the table... (In my example I am just pushing it to a context variable that is bound to a UI element.

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->set_attribute(

EXPORTING

name = `TEXT`

value = wd_this->SELELECTED_ELEMENT ).

where `TEXT` is an attribute in a context node.

...in case you need to to push it to a table the you will need to add this entry into the node that is mapped to your table.....

- let me know if this helps!

- Harish.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Darshna,

You will get the selected entry from the following code.

*           get element via lead selection
ELEM_N_C_101002 = NODE_N_C_101002->GET_ELEMENT( SY-INDEX ).

If te Item list box is not a table then let me know what it is??? Is it Dorpdownby key or index???????

Warm Regards,

Vijay.

Former Member
0 Kudos

Hi,

You have add a handler to the onLeadSelect event and in that you can get the lead selection and store the element value in a context or in an assistance class attribute.

And on the onAction of the button you can then read this context or the attribute and then add it to the table.

I have a code sample for this is you need

- Harish.

Former Member
0 Kudos

Hi Harish,

Can you please give me the code sample for this.

@Vijay,

It is list box containing 14 hard coded entries. Also I am planning to retrieve

data from table. I can scroll thru the list and all 14 entries are visible.

I need to select one of them.

Cheers,

Darshna

Former Member
0 Kudos

Hi Darshna,

Itemlist box has the event called onLeadSelect which has the values like Id, context_element and index. so whenever you select an entry from the list, then the this event will be traiggered and you can cacth the value using the index and you can write the logic whatever you want.

Warm Regards,

Vijay