ALV 或任何其他网格布局中的两级列标题?
为了说明我想要什么:
| Category A | Category B | C | | A.A | A.B | A.A | A.B | | | A.A.A | A.A.B | A.B.A | A.B.B | B.A.A | B.A.B | B.B.A | B.B.B | |
我需要一个看起来有点像这样的标题,我想知道除了手动写入每一行之外是否还有其他方法可以做到这一点。 :D
To illustrate what I want:
| Category A | Category B | C | | A.A | A.B | A.A | A.B | | | A.A.A | A.A.B | A.B.A | A.B.B | B.A.A | B.A.B | B.B.A | B.B.B | |
I need a header that looks somewhat like this and I was wondering if there's a way to do it other than manually WRITE each line. :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
cl_gui_alv_grid
中的内部表mt_data[]
保存有关前端如何显示网格的信息。每个单元格都用以下字段表示在单独的行中:事实证明,您可以将
mergehoriz
(和mergevert
)设置为一个整数,该整数定义了将有多少相邻单元格合并到单元格中。为了更改该表,我创建了一个cl_gui_alv_grid
子类,并实现了redraw
方法,我就是这样做的。这是我为此创建的演示报告。您需要一个带有自定义容器“CC”的 dynpro“100”以及带有退出命令的状态“STATUS_0100”来运行它。
为了完成 dynpro 100:
这是生成的网格:
我调用
redraw
方法来更改mt_data[]
并使用set_data_table
将其保存到网格的实际数据表中代码>.请注意,调用refresh_table_display
将消除这些更改,并且您必须在每次之后调用redraw
来跟进。此外,工具栏功能会破坏合并,因此您也必须手动实现它们。
这显然离完美还很远,但我认为这是一个不错的基础。
The internal table
mt_data[]
incl_gui_alv_grid
holds information about how the frontend shows the grid. Each cell is represented in a separate line with these fields:It turns out you can set
mergehoriz
(andmergevert
) to an integer that defines how many adjesent cells will merge into the cell. In order to change that table I created a sub-class tocl_gui_alv_grid
and implemented the methodredraw
where I do just that.Here's a demo report I created for this. You need a dynpro "100" with a custom container "CC" on it and a status "STATUS_0100" with an exit-command to run it.
For completion the dynpro 100:
This is the resulting grid:
I call the
redraw
method to changemt_data[]
and save it to the actual data table of the grid withset_data_table
. Note that callingrefresh_table_display
will get rid of these changes and you would have to follow this up with callingredraw
afterwards every time.Also, the toolbar functions will break the merge so you'd have to implement them by hand too.
This is obviously very far from perfect, but I think it's a decent foundation to work up from.
根据具体情况,您也许可以使用 XXL API 在 Excel 中生成列表。尝试执行演示程序 XXLFTEST 并将其结果导出到数据透视表 - 也许您可以使用这个?除此之外,据我所知没有任何控件能够做到这一点。当然,您可以自己编写这些内容,或者您可以尝试说服用户在垂直轴上具有层次结构并使用标准的列树......
Depending on the scenario, you might be able to bend the XXL API to generate the list in Excel. Try executing the demo program XXLFTEST and have it export the results to a pivot table - maybe you could use this? Other than that, I know of no control that is able to do this. You could WRITE the stuff yourself, of course, or you could try to persuade the users to have the hierarchy on the vertical axis and use a standard column tree...
根据我的经验,你不能在 ALV Grid 中做“多层”标题。但这可以通过使用 WRITE 语句的简单列表来完成,这使您可以更好地控制如何显示数据。
当然,排序、过滤等所有功能都必须自己完成。
最好的方法是坚持使用 ALV 网格,并按照 Harmut 的建议对数据进行子分类。您可以按此子类别列对它们进行排序,这样它看起来就像在 ALV 网格中分组在一起
Based on my experience, you can't do "multi-layer" header in ALV Grid. But this can be done with simple list using WRITE statements which gives you more control on how to display the data.
But of course you have to do all the functions like Sort, Filter and so on by yourself.
The best way is to stick with ALV Grid and just Sub-categorize your data with columns just as Harmut suggested. You can sort them by this sub-category column so it will look like grouped together in the ALV Grid