Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Tree Context Menu

Former Member
0 Likes
1,291

Hello Friends,

We are working on ALV Trees.

this is the sample code:

<b>CLASS LCL_TREE_EVENT_RECEIVER DEFINITION.

PUBLIC SECTION.

METHODS: HANDLE_NODE_CM_REQ

FOR EVENT NODE_CONTEXT_MENU_REQUEST OF CL_GUI_ALV_TREE

IMPORTING NODE_KEY MENU.

ENDCLASS. </b>

<b>CLASS LCL_TREE_EVENT_RECEIVER IMPLEMENTATION.

METHOD HANDLE_NODE_CM_REQ.

CALL METHOD MENU->CLEAR.

CALL METHOD MENU->ADD_FUNCTION

EXPORTING

FCODE = 'DEL_SUBTREE'

TEXT = 'Delete Subtree'. "Delete Subtree

CALL METHOD MENU->ADD_FUNCTION

EXPORTING

FCODE = 'ADD_SUBTREE'

TEXT = 'Add Subtree'. "Add Subtree</b>

Then we handle the node that is selected by the user.

Now our problem is can the context menu be created dynamically based on the node selected.

For example:

If my ALV Tree is

<b>Node A

>Node B

>>Node C

>Node B

>>Node C</b>

So, if I right click on Node A, I should get only 'Add B' or 'Delete B'.

if I click on Node B, I should get 'Add C' or 'Delete C'.

Depending on the node on which I right click the context menu should change. How to achieve that.

regards,

Raju.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
785

Hi,

The method HANDLE_NODE_CM_REQ FOR EVENT NODE_CONTEXT_MENU_REQUEST has NODE_KEY as importing paramer.

Use that NODE_KEY in method GET_OUTTAB_LINE' and get the node details.

Based on that you use 'Add Function' to have a relevant context menu.

Use Method GET_FIRST_CHILD to identify the child nodes.

Hope this helps

Regards

Immanuel D

1 REPLY 1
Read only

Former Member
0 Likes
786

Hi,

The method HANDLE_NODE_CM_REQ FOR EVENT NODE_CONTEXT_MENU_REQUEST has NODE_KEY as importing paramer.

Use that NODE_KEY in method GET_OUTTAB_LINE' and get the node details.

Based on that you use 'Add Function' to have a relevant context menu.

Use Method GET_FIRST_CHILD to identify the child nodes.

Hope this helps

Regards

Immanuel D