解决方法
首先,我发现
Vaadin docs是一个开始寻求帮助的好地方.对于剩下的练习,假设我们有一个带有3个简单列c1,c2和c的网格. C3:
Grid grid = new Grid(); grid.addColumn("c1",String.class); grid.addColumn("c2",String.class); grid.addColumn("c3",String.class);
1.) How to disable the sort function in the Header of each column
遍历每个列并将其sortable属性设置为false:
for (Grid.Column column : grid.getColumns()) { column.setSortable(false); }
grid.getColumn("c1").setSortable(false);
2.) How to set the color of one column in a Grid table
与was done with the table类似,您需要在theme中定义CSS样式:
@import "../valo/valo.scss"; @mixin mytheme { @include valo; // Insert your own theme rules here .v-grid-cell.green { background: #33BB00; } }
并使用CellStyleGenerator将样式应用于所需的列:
grid.setCellStyleGenerator(new Grid.CellStyleGenerator() { @Override public String getStyle(Grid.CellReference cellReference) { if ("c1".equals(cellReference.getPropertyId())) { return "green"; } else { return null; } } });