将 ALV 输出网格中的复选框标记为选中
Mark checkboxes in ALV output grid as selected
我正在使用 class cl_gui_alv_grid
创建 ALV 输出网格。使用字段目录的相应记录将输出 table 的其中一列定义为复选框:
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
对于包含复选框的列的所有记录,它们都设置为未选中。我的问题是我可以实现什么逻辑才能使某些行的复选框在显示 ALV 时设置为选中状态。
如果您想根据 alv 网格中最初显示的数据设置复选框,只要条件匹配,只需在 outtab 复选框字段中填写 abap_true (='X')。如果您 不 使用 fieldcatalog 的复选框参数,您只会看到 'X' 表示选中,' ' 表示未选中。
如果要根据用户输入设置复选框,在他们编辑了 alv 网格中的某些字段后,使用以下 alv 网格事件更改 outtab:
METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_data_changed_finished FOR EVENT data_changed_finished OF cl_gui_alv_grid, "executed only if no errors, outtab holds changed data
我还发现了一些我在不得不处理这些事件时发表的评论
*&---------------------------------------------------------------------*
*& Method handle_data_changed
*&---------------------------------------------------------------------*
* raised when at least one cell is modified in the ALV
* - modified entries are not stored in gt_outtab yet, but er_data_changed object
* - mt_good_cells holds every changed field thats valid according to type declaration
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Method handle_data_changed_finished
*&---------------------------------------------------------------------*
* - raised when data validation is valid
* - NOW outtab holds valid changed data
*----------------------------------------------------------------------*
我正在使用 class cl_gui_alv_grid
创建 ALV 输出网格。使用字段目录的相应记录将输出 table 的其中一列定义为复选框:
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
对于包含复选框的列的所有记录,它们都设置为未选中。我的问题是我可以实现什么逻辑才能使某些行的复选框在显示 ALV 时设置为选中状态。
如果您想根据 alv 网格中最初显示的数据设置复选框,只要条件匹配,只需在 outtab 复选框字段中填写 abap_true (='X')。如果您 不 使用 fieldcatalog 的复选框参数,您只会看到 'X' 表示选中,' ' 表示未选中。
如果要根据用户输入设置复选框,在他们编辑了 alv 网格中的某些字段后,使用以下 alv 网格事件更改 outtab:
METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_data_changed_finished FOR EVENT data_changed_finished OF cl_gui_alv_grid, "executed only if no errors, outtab holds changed data
我还发现了一些我在不得不处理这些事件时发表的评论
*&---------------------------------------------------------------------*
*& Method handle_data_changed
*&---------------------------------------------------------------------*
* raised when at least one cell is modified in the ALV
* - modified entries are not stored in gt_outtab yet, but er_data_changed object
* - mt_good_cells holds every changed field thats valid according to type declaration
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Method handle_data_changed_finished
*&---------------------------------------------------------------------*
* - raised when data validation is valid
* - NOW outtab holds valid changed data
*----------------------------------------------------------------------*