如何将生成的列添加到Vaadin 8 Grid? [英] How to add a generated column to Vaadin 8 Grid?

查看:82
本文介绍了如何将生成的列添加到Vaadin 8 Grid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Vaadin 8中不存在类似GeneratedPropertyContainer这样的外观.

Looks like GeneratedPropertyContainer does not exist in Vaadin 8.

如何将生成的列添加到Vaadin 8 Grid?谢谢您能提供一个例子.

How can we add a generated column to Vaadin 8 Grid? I appreciate if you can provide an example.

推荐答案

如果将Bean类传递给Grid的结构,则它将所有属性作为列添加到网格.

If you pass the bean class to the constructure of Grid then it will add all properties as columns to the grid.

如果您只希望将某些属性用作列,则不要将类传递给构造函数,并手动添加列,如下所示:

If you want to only have some properties as columns then don't pass the class to the constructor and add your columns manually like this:

grid.addColumn(Address::getStreet);
grid.addColumn(Address::getHouseNumber);
grid.addColumn(Address::getPostalCode);
grid.addCOlumn(Address::getCity);

如果要添加生成的列,只需使用addColumn添加它

If you want to add a generated column just add it with addColumn

grid.addColumn(address -> {
  // put your calculations for the column here
  return address.getStreet() + " " + address.getHouseNumber();
});

这篇关于如何将生成的列添加到Vaadin 8 Grid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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