2010年8月6日

CL_GUI_ALV_GRID 取消右鍵功能

在網上看到有人問到這個技術怎麼做,一時興起就做起來了

首先宣告EVENT_RECEIVER
DATA: GRID TYPE REF TO CL_GUI_ALV_GRID,
EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.

再寫code,重點在event CONTEXT_MENU_REQUEST,將E_OBJECT清空
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS:
HANDLE_CONTEXT_MENU_REQUEST
FOR EVENT CONTEXT_MENU_REQUEST OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT.
ENDCLASS.
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_CONTEXT_MENU_REQUEST.
CALL METHOD E_OBJECT->CLEAR.
ENDMETHOD.
ENDCLASS.

再來就是將event掛到grid去
CREATE OBJECT EVENT_RECEIVER.
SET HANDLER EVENT_RECEIVER->HANDLE_CONTEXT_MENU_REQUEST FOR GRID1.

沒有留言:

張貼留言