我想在编辑另一个字段时填充一个字段。所以这就是实现中的方法。
当我按Enter键时,不会发生任何事情,但当我双击时,更改将应用。
你有什么想法或解决办法吗?我正在使用类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.
因此,正如我在评论中所说,很明显,这个问题更多地是关于CL_GUI_ALV_GRID
(而不是CL_SALV_TABLE(。默认情况下,Enter键不会触发事件DATA_CHANGED
和DATA_CHANGED_FINISHED
。
如果您想要此功能,则必须调用方法REGISTER_EDIT_EVENT
,并传递这两个常量中的一个,以便同步激发两个事件:
- MC_EVT_ENTER:按下ENTER键时,即使没有更改任何单元格,事件也将始终被触发
- MC_EVT_MODIFIED:一旦一个单元格被更改,按下Enter键或焦点被更改为另一个单元格,事件就会被触发