表格合并单元格 - Vaadin [英] Table merge cells - Vaadin

查看:48
本文介绍了表格合并单元格 - Vaadin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Vaadin 创建表格.一些细胞正在重复.所以我希望它们合并在一个单元格中,正如您在图像上看到的:

I'm Creating table with Vaadin. Some of the cells are repeating. So I want them to merge in one cell, as you can see on the image:

第一张图片显示了表格现在的样子,第二张是我想要合并单元格的样子.

The first image show how the table looks now, and the second is how I want to look with merged cells.

我正在使用此代码:

Table table = new Table(AppData.getMessage("menu.report2"));
table.addContainerProperty(tableHeaders[0], String.class, null);
table.addContainerProperty(tableHeaders[1], String.class, null);
table.addContainerProperty(tableHeaders[2], String.class, null);
table.addContainerProperty(tableHeaders[3], String.class, null);

List<User> employeeList = employeeDAO.findAllEmployees();
int i;
for (i = 0; i < employeeList.size(); i++) {
    User employee = employeeList.get(i);
    table.addItem(new Object[]{
            CaseStatus.OPEN,
            tasksDAO.countTasks(CaseStatus.OPEN),
            employee.getFirstAndLastName(),
            tasksDAO.countTasks(employee, CaseStatus.OPEN)},
            i);
}

for (int j = 0; j < employeeList.size(); j++) {
    User employee = employeeList.get(j);
    table.addItem(new Object[]{
            CaseStatus.CLOSED,
            tasksDAO.countTasks(CaseStatus.CLOSED),
            employee.getFirstAndLastName(),
            tasksDAO.countTasks(employee, CaseStatus.CLOSED)},
            i + j);
}


table.setPageLength(table.size());

addComponent(table);
setComponentAlignment(table, Alignment.TOP_CENTER);
setMargin(true);

推荐答案

我认为,这在正常方式"中是不可能的.但我知道如何模拟这个.

I think, this is not possible in "normal way". But I have an idea how to simulate this.

第一个解决方案:

您可以根据需要简单地使用 GridLayout 来构建网格.那么除了这种网格的大小之外,没有什么能限制你的想象力.它不应该太大(还指出了此处).

You could simply use GridLayout to build grid as you want. Then nothing limit your imagination beside size of such grid. It shouldn't be to big (also pointed here).

第二种解决方案:

另一个建议有点疯狂.

  1. 禁用 Table/Grid 条纹.
  2. 在一组相似的单元格中,只填充第一行.留空(或字符串中的空格).

然后处理重复数据(来自第一列和第二列),但不能垂直对齐它们(文本将保留在顶部 - 组中的第一行).

Then you dispose of repeated data (from your first and second column), but you can't alignment them vertically (the text will stay at top - first row from group).

第三种解决方案:

检查附加组件列表.例如 ItemGrid.

这篇关于表格合并单元格 - Vaadin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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