gpt4 book ai didi

vaadin - 更改网格中单元格的颜色(Vaadin)

转载 作者:行者123 更新时间:2023-12-03 23:49:35 26 4
gpt4 key购买 nike

我在 Grid 中使用 BeanItemContainer 来显示我的数据。我需要根据单元格中的数据分别为每个单元格着色。

最佳答案

section about the Grid在 Vaadin 的书中,在 Generating Cell Styles 小节中解释了这一点:

You set a CellStyleGenerator to a grid with setCellStyleGenerator(). The getStyle() method gets a CellReference, which contains various information about the cell and a reference to the grid, and should return a style name or null if no style is generated.

For example, to add a style name to a specific column, you can match on the property ID of the column as follows:

grid.setCellStyleGenerator(cellRef -> // Java 8
"born".equals(cellRef.getPropertyId())?
"rightalign" : null);

You could then style the cells with a CSS rule as follows:

.v-grid-cell.rightalign {
text-align: right;
}

关于vaadin - 更改网格中单元格的颜色(Vaadin),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32843850/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com