2015-05-04 133 views
0

我已經在Vaadin的幫助下在Eclipse中創建了一個表格。Vaadin - 刪除表格中的單元格邊框

我設法與下面的行刪除表格的邊框:

tblResetButton.addStyleName(Reindeer.TABLE_BORDERLESS) ; 

但這仍然給我留下了一條垂直線是這樣的:

example

有沒有一種辦法隱藏所有的單元格邊框?和一個額外的獎金,纔有可能給第一個單元格(具有「Gebruiker」)的顏色#F4F4F4和第二細胞(文本)顏色#E2E2E2


編輯:

的formlayout會很好,但我似乎無法得到背景顏色的工作,所以我回到了桌子上。這是代碼:

JAVA

tblReset.addContainerProperty("Gebruiker", String.class, null); 

tblReset.setCellStyleGenerator(new Table.CellStyleGenerator() { 
      @Override 
      public String getStyle(Table source, Object itemId, Object propertyId) { 
       if("Gebruiker".equals(propertyId)){ 
        return "style-name-with-black-background"; 
       } else { 
        return "style-name-with-yellow-background" ; 
       } 
      } 
     }); 

CSS

.style-name-with-black-background { 
    background-color: black ; 
} 

.style-name-with-yellow-background { 
    background-color: yellow ; 
} 
+1

只是把它問:你不打算濫用表是一個的FormLayout? – cfrick

+0

第一次Vaadin用戶,所以我要檢查出 – Noosrep

+0

表單佈局的問題是什麼?您是否檢查過[表單樣式的書籍部分](https://vaadin.com/book/-/page/layout.formlayout.html)? – Morfic

回答

0

假設的答案cfrick的評論是否定的,看起來像它取決於你使用的是什麼主題:

風格添加到表

table.setStyleName("no-vertical-lines-or-border"); 

而在你的主題定義它

.v-table-no-vertical-lines-or-border .v-table-header-wrap /* remove header-table borders */, 
    .v-table-no-vertical-lines-or-border .v-table-body /* remove body-table borders */, 
    .v-table-no-vertical-lines-or-border .v-table-cell-content /* remove cell borders */ { 
    border: none; 
    } 

至於細胞,您可以使用style generator,再次爲每個單元格定製樣式,s沿線的omething:

table.setCellStyleGenerator(new Table.CellStyleGenerator() { 
     @Override 
     public String getStyle(Table source, Object itemId, Object propertyId) { 
      if("description".equals(propertyId)){ 
       return "style-name-with-F4F4F4-background"; 
      } else { 
       return "style-name-with-E2E2E2-background"; 
      } 
     } 
    }); 

PS:假設你正在嘗試,如果你正在使用Vaadin版本7.2+工作,看看在support for font icons這可能會在時間非常方便,例如嵌入式FontAwesome

FontAwesome basic usage

+0

主題是馴鹿。我更新了這個問題,你可以看一下嗎? – Noosrep

+0

@TimothyPersoon就像我說的,你必須手動定義一個表格來刪除他的邊界,請看更新答案。 – Morfic

+0

它的工作原理,謝謝! – Noosrep