Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CL_GUI_ALV_GRID's event CLICK_ROW_COL

Hello,

in order to allow the user a single click on any cell within the alv grid I would like

use CL_GUI_ALV_GRID's event CLICK_ROW_COL .

It is protected so I can't use that. What I can do in this case ?

Thx in advance for your help.

Spielwiese

Former Member
replied

Look at this code:

CLASS lcl_gui_alv_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
"        Hotspot click control
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid   
                               IMPORTING e_row_id e_column_id es_row_no.    "this will be passed each time your click on the cell
ENDCLASS. 

CLASS lcl_gui_alv_event_receiver IMPLEMENTATION.

  METHOD handle_hotspot_click .
    DATA: l_mess TYPE string,
          l_row(2) TYPE c.

    WRITE es_row_no-row_id TO l_row.
    CONCATENATE 'Hotspot click at: ' e_column_id-fieldname 'in'
                                     l_row 'row.'
                                     INTO l_mess SEPARATED BY space.
    MESSAGE l_mess TYPE 'I'.    "here for example an info message will pop up with cell address
  ENDMETHOD .                    "handle_hotspot_click
ENDCLASS.

DATA: "alv event receiver class
      g_alv_event_ref TYPE REF TO lcl_gui_alv_event_receiver.

CREATE OBJECT g_alv_event_ref.

"set handler for your alv
SET HANDLER g_alv_event_ref->handle_hotspot_click FOR g_alv_grid_ref. "here g_alv_grid_ref must hold your alv grid reference

Regards

Marcin

2 View this answer in context
Not what you were looking for? View more on this topic or Ask a question