abap - 动态着色 ALV 网格的单元格 (CL_SALV_TABLE)
问题描述
我需要动态地为 ALV Grid 的单元格着色。我用CL_SALV_TABLE
.
例如,在我的情况下,我根据参数从数据表中选择数据。我想在 ALV 网格中显示选定的结果。-> 到目前为止,一切都按我的需要工作。
现在,我想将网格中具有初始值或零值的单元格着色为红色。
这可能吗?如果是,该怎么做?
解决方案
将另一列添加type lvc_t_scol
到最终输出表中,填充它并告诉 ALV 将其用作颜色列。
* declaration of output table with color column
TYPES: BEGIN OF lty_output,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
color TYPE lvc_t_scol,
END OF lty_output.
DATA gt_output TYPE STANDARD TABLE OF lty_output.
* filling color column of output table (e.g. based on condition during a LOOP)
DATA: ls_color TYPE lvc_s_scol,
lt_color TYPE lvc_t_scol.
gt_output = VALUE #(
( carrid = 'AA' carrname = 'American Airlines' color = VALUE #(
( fname = 'CARRNAME' color = VALUE #( col = 6 int = 0 inv = 0 ) ) ) )
( carrid = 'AF' carrname = 'Air France' color = VALUE #(
( fname = 'CARRID' color = VALUE #( col = 7 int = 0 inv = 0 ) )
( fname = 'CARRNAME' color = VALUE #( col = 5 int = 0 inv = 0 ) ) ) )
( carrid = 'LH' carrname = 'Lufthansa' color = VALUE #(
( fname = '' color = VALUE #( col = 3 int = 0 inv = 0 ) ) ) ) ).
cl_salv_table=>factory(
IMPORTING
r_salv_table = DATA(go_alv)
CHANGING
t_table = gt_output ).
* setting color column
go_alv->get_columns( )->set_color_column( 'COLOR' ).
go_alv->display( ).
推荐阅读
- python - 如何使用 Qt 获取视频缩略图
- java - 使用 vertx-jooq-classic-reactive: 5.0.1 编写期货时出现错误连接未打开关闭
- c# - 函数应用程序给出异常 HTTP 错误 500.30 - ANCM 进程中启动失败
- html - 元素的宽度取决于另一个元素的宽度 - 没有 JavaScript
- swift - SwiftUI 导航栏即使隐藏也有多余空间
- sql-server - 如何在 SQL Server 中保存更改?
- c# - HashSet 中的哈希性能
针对列表 包含 - c# - ServiceChannel Object is more in memory dump of webapi
- flutter - 无法从静态方法 dart 访问实例成员
- java - Why is this legal in Java? Queue
waitingQueue = new LinkedList<>();