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

context menu on tree structure

Former Member
0 Likes
1,933

HI,

I'm using the class CL_SALV_TREE inorder to show a screen like tree stucture..now i wanna add a context menu on that tree

structure..

is it possible to add a context menu.if so can u explain the steps how to do it?...

Thanks in advance,

poornima.

5 REPLIES 5
Read only

Former Member
0 Likes
1,288

Hi,

There is a demo program which can give you a good example as to how to implement the context menu. Have a look at it.

SAPSIMPLE_TREE_CONTEXT_MEN_DEM package - SEU_TREE_CONTROL.

Hope this will help.

Thanks,

Samantak.

Read only

0 Likes
1,288

hi,

thanks for ur reply..but the thing is the program which u gave was implemented using the class cl_gui_simple_tree ,so it contains

default context menu method..but in my program i'm using the class CL_SALV_TREE,CL_SALV_EVENTS_TREE..

my question is how come we can implement the context menu for this class which doesnt have default context menu method..

is it possible to intergate some other events..if it so plz tell me..

Thanks ,

Poornima

Read only

0 Likes
1,288

Hi,

Can you have a look at this Demo Report Program : BCALV_TREE_03. Package - SLIS.

Hope this will help you.

Thanks,

Samantak.

Read only

former_member418469
Participant
0 Likes
1,288

hi,

Use CL_CTMENU for context menu.

Use can also try CL_COLUMN_TREE_MODEL for creating tree structure.

Read only

naimesh_patel
Active Contributor
0 Likes
1,288

CL_SALV_TREE creates a Tree type reference to the class CL_SALV_GUI_TREE which is inherited from the class CL_GUI_ALV_TREE. So, to get the Context Menu on the tree created by the CL_SALV_TREE, you need to :

Define Event Receiver class:


class lcl_handle_events definition.
  public section.
      on_header_context_menu_req for EVENT header_context_menu_request of cl_gui_alv_tree  " <<
        IMPORTING FIELDNAME
                  menu.
endclass.                    "lcl_handle_events DEFINITION

Implement the class:


class lcl_handle_events implementation.
  method on_header_context_menu_req.
*  Access the MENU object
  ENDMETHOD.
endclass.                    "lcl_handle_events IMPLEMENTATION

Now, here is the trick. Set the Event Handler for ALL INSTANCE rather than setting it for the specific instance before calling the DISPLAY method.


    data: gr_events type ref to lcl_handle_events.

    SET HANDLER gr_events->on_header_context_menu_req  FOR ALL INSTANCES . "mr_column_tree.

*... §5 display the table
    gr_tree->display( ).

Same way, you can try to trap the other Context Menu events like ITEM_CONTEXT_MENU_REQUEST, ITEM_CONTEXT_MENU_SELECTED.

Regards,

Naimesh Patel