如何防止网格变得小于最小高度?

How can I prevent that the grid becomes smaller than a minimal height?

我使用 vaadin-grid 并希望在 select 编辑一行时使用行详细信息视图。只要 table 有很多行,这就有效。假设您过滤了一些 table 数据并且 table 变小了

当您 select 一行时,您将无法再看到行详细信息视图,因为网格太小了。

如何防止网格变得小于最小高度?

您可以使用数据容器在详细信息生成器中重新计算网格高度。它不是最终的解决方案,但它非常适合我的需求,即动态改变网格高度而内部没有滚动条。

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()
   }
}

希望有所帮助。如果您找到更好的解决方案,请在此处post。我没有检查但是如何将组件标记为脏内部详细信息生成器?