2016-02-07 44 views
0

我使用vaadin-grid並希望在選擇行時使用行詳細信息視圖。只要表格有很多行,這就可以工作。假設你過濾掉一些表數據和表變小如何防止網格變得比最小高度小?

enter image description here

當你選擇了某一行,你是不是能夠看到行詳細信息查看了,因爲電網太小

如何防止網格變得比最小高度小?

回答

0

您可以使用數據容器重新計算細節生成器內的網格高度。它不是最終的解決方案,但它適用於我的需要,它可以動態地改變網格高度而不需要滾動條。

Grid table... 
table.setHeightMode(HeightMode.ROW); 
table.setDetailsGenerator(new DetailsGenerator() { 

    public Component getDetails(RowReference rowReference) { 
     table.setHeightByRows(tableContainer.getItemIds().size() + 4); 
     //detalis height is constant so I solve this by adding extra space which equals the size of 4 the rows 
     // 
     //for filtered container you can use tableContainer.getVisibleItemIds() 
    } 
} 

希望有所幫助。如果你找到更好的解決方案,請在這裏發佈。我沒有切開,但是如何將組件標記爲細節生成器中的髒東西?