How to add a generated column to Vaadin 8 Grid?

跟風遠走 提交于 2019-12-04 05:47:10

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);

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();
});

A generated column would work like this:

grid.addColumn(address->address.getStreet()+" "+address.getHouseNumber()).setCaption("Street");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!