简体   繁体   中英

data_change using cl_gui_alv_grid - not reacting to Enter key

I want to populate a field when another field was edited. So this is the method in the implementation.

When I press Enter nothing happens, but when i double click the change applies.

Do you have any idea or fix? I am using the class cl_gui_alv_grid.

METHOD data_changed_finished.
DATA: ls_inr   TYPE LINE OF lvc_t_modi,
      lv_stbl  TYPE lvc_s_stbl,
      gt_out type standard table of SPFLI,
      ls_out   LIKE LINE OF gt_out.


LOOP AT et_good_cells INTO ls_inr
  WHERE fieldname = 'CITYFROM'. 
  EXIT.
ENDLOOP.

DATA:
  ld_REFRESH_MODE TYPE SALV_DE_CONSTANT ,
  ld_S_STABLE TYPE LVC_S_STBL.
  ld_S_STABLE-row = 'X'.
  ld_S_STABLE-col = 'X'.

IF sy-subrc = 0.
  LOOP AT et_good_cells INTO ls_inr.
    LOOP AT IT_SPFLI INTO ls_out
                   FROM ls_inr-row_id
                   TO ls_inr-row_id.
      
      ls_out-DISTANCE = '556'.
      MODIFY IT_SPFLI FROM ls_out.

    ENDLOOP.
  ENDLOOP.

ENDIF.


  lv_stbl-row = 'X'.
  lv_stbl-col = 'X'. 

  ld_S_STABLE-row = 'X'.
  ld_S_STABLE-col = 'X'.
  ld_REFRESH_MODE = 2. 
  
  CALL METHOD salv->REFRESH(
  EXPORTING
  REFRESH_MODE = ld_REFRESH_MODE
  S_STABLE = ld_S_STABLE ).

ENDMETHOD.

So, as I said in the comments, it's obvious to me that the question is more about CL_GUI_ALV_GRID (not CL_SALV_TABLE). By default the Enter key does not trigger the events DATA_CHANGED and DATA_CHANGED_FINISHED .

If you want this feature, you must call the method REGISTER_EDIT_EVENT and pass one of these two constants for a synchronous firing of the two events :

  • MC_EVT_ENTER : the events will always be fired when Enter is pressed, even if no cells have been changed
  • MC_EVT_MODIFIED : the events will be fired as soon as one cell is changed and either Enter is pressed or the focus is changed to another cell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM