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

让人想犯罪 __ 提交于 2019-12-23 02:44:20

问题


I'm using Vaadins Grid table for data representation. Therefore I want to draw a thick line for the right border of the Employee-ID-column and for both border sides of the name or name and surname column.

The result should look like this:

How I can manage that?


回答1:


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:




回答2:


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.



来源:https://stackoverflow.com/questions/35677935/vaadin-grid-table-how-to-draw-border-for-certain-columns

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