cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the pressed item value of Tree UI Element??

Former Member
0 Kudos

There is a tree like below:

Tree

Treenode1

tree_item1

tree_item2

Treenode2

tree_item3

tree_item4

tree_item5

how can I get the value of tree_item1,2,3... after they were been pressed?? Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

What exactly do you mean by When they were pressed. lead selected or do you have any link.

If you want to get the lead selected element, simply you can use node->get_lead_selection( ) which returns you element and using get_static_attributes( ) method you can get the values of that element.

If you want ot get the value when you press some link, have an action handler for that link and in the action handler method you can get the current element using wdevent's get_context_element method ( wdevent->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ) which returns element. From element you can get values using get_static_attributes or get_attribute methods.).

Thanks,

Prasahnth

Former Member
0 Kudos

Thanks,Prasahnth, in this tree, there is one leaf name 'SFLIGHT', after click this leaf, value 'SFLIGHT' will be got and to be showed with ALV control.

I just need to get the value 'SFLIGHT', that is the table will be output by ALV later.

could you please show some example codes of this? thanks once more.

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks all, I had got the value by below codes:

data parent_element TYPE REF TO if_wd_context_element.

parent_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

parent_element->get_attribute( EXPORTING name = 'VALUE' IMPORTING value = tablename ).

then the table name is 'SFLIGHT", just what I need.

Thanks so much for your kind help!!!

Former Member
0 Kudos

Hi,

Define an event handler for the OnAction event of the tree. The method would have wdevent as an importing parameter. You can use the method call wdevent->get_string('ID'), which will return the UI element ID of the item that has been clicked. Else you can use wdevent->get_context_element( ).

Refer to the webdynpro component WDR_TEST_EVENTS that has various types of trees. Hope this helps.

Regards,

Nithya