09-11-2011 1:41 PM
Hello ABAP experts,
I have developed a program which shows some output in ALV grid (CL_GUI_ALV_GRID). I don't want the user to play with columns and rows of grid, so I have removed toolbar using following:
LVC_S_LAYO-NO_TOOLBAR
I have noticed, still user can hide or show columns and delete rows by right clicking on the grid. I want to disable right click or context menu. I am unable to get any hint so far.
I appreciate for some good solution.
Thanks,
Waqas Rashid
09-11-2011 3:03 PM
Hi,
Just as stated by Max you can use the event 'CONTEXT_MENU_REQUEST' in the class 'CL_GUI_ALV_GRID'. In fact I just tried out calling the event. I set the handler for the event 'CONTEXT_MENU_REQUEST'. And then in the implementation I just called the clear method. Example is below.
class lcl_events_split definition.
public section.
methods:
CONTEXT_MENU_REQUEST for event CONTEXT_MENU_REQUEST
of cl_gui_alv_grid importing E_OBJECT.
endclass. "lcl_events_split DEFINITION
class lcl_events_split implementation.
method CONTEXT_MENU_REQUEST.
e_object->CLEAR( ). "THIS SHOULD STOP THE RIGHT CLICK MENU BAR
endmethod.
endclass.
CREATE OBJECT O_CC
EXPORTING CONTAINER_NAME = 'CC_ALV'.
CREATE OBJECT O_ALV
EXPORTING I_PARENT = O_CC.
And before you call you grid for display below code is required.
data: ls_spl_events type ref to lcl_events_split. "Event Handler class
set handler ls_spl_events->CONTEXT_MENU_REQUEST for O_ALV.
CALL METHOD O_ALV->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = T_MARA
IT_FIELDCATALOG = LS_FIELDCATALOG.
Hope this helps ......
Regards,
Imran,
Edited by: Mujtaba Imran on Sep 11, 2011 7:34 PM
09-11-2011 2:26 PM
Hi
have you tried to exclude those functions? I means to transfer the ok-code to parameter it_toolbar_excluding of method set_table_for_first_display.
U can also check the event CONTEXT_MENU_REQUEST
Max
09-11-2011 3:03 PM
Hi,
Just as stated by Max you can use the event 'CONTEXT_MENU_REQUEST' in the class 'CL_GUI_ALV_GRID'. In fact I just tried out calling the event. I set the handler for the event 'CONTEXT_MENU_REQUEST'. And then in the implementation I just called the clear method. Example is below.
class lcl_events_split definition.
public section.
methods:
CONTEXT_MENU_REQUEST for event CONTEXT_MENU_REQUEST
of cl_gui_alv_grid importing E_OBJECT.
endclass. "lcl_events_split DEFINITION
class lcl_events_split implementation.
method CONTEXT_MENU_REQUEST.
e_object->CLEAR( ). "THIS SHOULD STOP THE RIGHT CLICK MENU BAR
endmethod.
endclass.
CREATE OBJECT O_CC
EXPORTING CONTAINER_NAME = 'CC_ALV'.
CREATE OBJECT O_ALV
EXPORTING I_PARENT = O_CC.
And before you call you grid for display below code is required.
data: ls_spl_events type ref to lcl_events_split. "Event Handler class
set handler ls_spl_events->CONTEXT_MENU_REQUEST for O_ALV.
CALL METHOD O_ALV->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = T_MARA
IT_FIELDCATALOG = LS_FIELDCATALOG.
Hope this helps ......
Regards,
Imran,
Edited by: Mujtaba Imran on Sep 11, 2011 7:34 PM
09-12-2011 7:12 AM