Robo
(Robo Ninja)
1
Can somebody help converting this from 7 to 8?
grid.setCellDescriptionGenerator(new Grid.CellDescriptionGenerator() {
@Override
public String getDescription(Grid.CellReference cellReference) {
c1 = "cell1".equals(cellReference.getPropertyId());
c2 = "cell2".equals(cellReference.getPropertyId());
c3 = "cell3".equals(cellReference.getPropertyId());
c4 = "cell4".equals(cellReference.getPropertyId());
descr = (String)cellReference.getItem().getItemProperty("description").getValue();
return ((c1 || c2 || c3 || c4)?descr:null);
}
});
Johannes10
(Johannes Häyry)
2
Grid<MyPojo> grid = new Grid<>(MyPojo.class);
grid.getColumns().stream()
.filter(column -> "cell1".equals(column.getId()) || "cell2".equals(column.getId())
|| "cell3".equals(column.getId()) || "cell4".equals(column.getId()))
.forEach(column -> column.setDescriptionGenerator(pojo -> pojo.getDescription()));
or with each individual column
private String getDescription(MyPojo pojo) {
return pojo.getDescription();
}
Grid<MyPojo> grid = new Grid<>(MyPojo.class);
grid.getColumn("cell1").setDescriptionGenerator(this::getDescription);
grid.getColumn("cell2").setDescriptionGenerator(this::getDescription);
grid.getColumn("cell3").setDescriptionGenerator(this::getDescription);
grid.getColumn("cell4").setDescriptionGenerator(this::getDescription);