ALV 动态显示和隐藏列
最近有个需求,需要在ALV上点个按钮隐藏和显示隐藏列(初始化的时候是隐藏的,点个按钮显示,再点一下隐藏在点显示)
GRID ALV
1、首先是初始化隐藏列,这个很简单,FIELDCAT-NO_OUT = ‘X’.
2、在刷新的时候,需要使用oo的刷新和fieldcat从新刷一遍就OK了
`
&---------------------------------------------------------------------
*& FORM REFRESH_ALV
&---------------------------------------------------------------------
-
TEXT
----------------------------------------------------------------------
- –> P1 TEXT
- <-- P2 TEXT
----------------------------------------------------------------------
FORM REFRESH_ALV .
DATA: LO_GRID TYPE REF TO CL_GUI_ALV_GRID,
LW_STABLE TYPE LVC_S_STBL.
DATA ET_FIELDCAT_LVC TYPE LVC_T_FCAT.
CLEAR:ET_FIELDCAT_LVC.
CALL FUNCTION ‘LVC_TRANSFER_FROM_SLIS’
EXPORTING
it_fieldcat_alv = GT_FIELDCAT[]
IMPORTING
ET_FIELDCAT_LVC = ET_FIELDCAT_LVC
TABLES
it_data = <FS_TABLE>
EXCEPTIONS
IT_DATA_MISSING = 1
.
CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR’
IMPORTING
E_GRID = LO_GRID.
CALL METHOD LO_GRID->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = ET_FIELDCAT_LVC.
LW_STABLE-ROW = ‘X’.
LW_STABLE-COL = ‘X’.
LO_GRID->REFRESH_TABLE_DISPLAY(
EXPORTING
IS_STABLE = LW_STABLE
EXCEPTIONS
FINISHED = 1
OTHERS = 2 ).
ENDFORM.`