将 ALV 输出网格中的复选框标记为选中 [英] Mark checkboxes in ALV output grid as selected

查看:58
本文介绍了将 ALV 输出网格中的复选框标记为选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 cl_gui_alv_grid 类创建 ALV 输出网格.使用fieldcatalog的对应记录将输出表的其中一列定义为复选框:

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') if condition 填充您的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆