将ALV输出网格中的复选框标记为选中状态 [英] Mark checkboxes in ALV output grid as selected
问题描述
我正在使用类 cl_gui_alv_grid
创建ALV输出网格。通过使用字段目录的相应记录,将输出表的列之一定义为复选框:
I am creating an ALV output grid using class cl_gui_alv_grid
. One of the columns of the output table is defined as a checkbox by using the corresponding record of the fieldcatalog:
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
对于包含复选框的列的所有记录,它们都设置为未选中。我的问题是我可以实现什么逻辑,以便对于某些行,在显示ALV时将复选框设置为选中状态。
For all the records of the column that contains the checkboxes, they are all set as unselected. My question is what logic can I implement in order that for some of the rows, the checkboxes to be set as selected when I display the ALV.
推荐答案
如果要根据alv网格中最初显示的数据设置复选框,则在条件匹配的情况下,只需用abap_true(='X')填充outtab复选框字段即可。如果您不使用fieldcatalog的复选框参数,则只会看到 X表示已选中,表示未选中。
If you want to set the checkbox according to initially shown data in the alv grid, just fill your outtab checkbox field with abap_true (='X') if condition is matched. If you would not use the checkbox parameter of the fieldcatalog you would just see 'X' for checked and ' ' for not checked.
如果您要根据用户输入设置复选框,在他们编辑了alv网格中的某些字段后,请使用以下alv网格事件更改outtab:
If you want to set the checkbox according to user input, after they edited some fields in the alv grid, use the following alv grid events to change 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
当我不得不处理这些事件时,我也发现了自己的一些评论
I also found some comments I made, when I had to deal with these events
*&---------------------------------------------------------------------*
*& 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
*----------------------------------------------------------------------*
这篇关于将ALV输出网格中的复选框标记为选中状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!