Vaadin Grid Table: how to draw border for certain columns?

断了今生、忘了曾经 提交于 2019-12-06 16:02:57
Morfic

Continuing from where we left off in your other question regarding cell background, update your CellStyleGenerator to handle your other columns. For the sake of brevity I'll just demo a column with both borders, but you'll get the idea:

grid.setCellStyleGenerator(new Grid.CellStyleGenerator() {
    @Override
    public String getStyle(Grid.CellReference cellReference) {
        if ("c1".equals(cellReference.getPropertyId())) {
            return "green";
        } else if ("c2".equals(cellReference.getPropertyId())) {
            return "right-and-left-border";
        } else {
            return null;
        }
    }
});

... add the appropriate styles in your theme file:

.v-grid-cell.right-and-left-border {
  border-left: solid 2px black;
  border-right: solid 2px black;
}

... and you should get something similar to:

kukis

You need to:

  1. Add style name to your grid component:

    Grid grid = new Grid();
    grid.addStyleName("grid-column-seperators")
    
  2. Then in your *.scss file you need to add css style for class .grid-column-separator that add thick lines in your grid as explained here

Remember to compile Vaadin theme before deploying your app to see desired effect.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!