Vaadin 13 Grid 中是否有一个 "Select All" checkbok(即使有过滤条件也能工作,甚至有些数据不在缓存中?)

is there a "Select All" checkbok in Vaadin 13 Grid (that works even with filter conditions & when even some of the data is NOT in the cache?)

在 Vaadin 13 中,我为我的网格启用了 "multiselect",效果很好。然而,通常,即使在过滤之后,我也有数百个项目(因此 select 对每个项目进行 select 处理会很乏味)。在我多年前使用的旧 gwt "grid" 工具中,他们有一个复选框,该复选框会出现在 row/header 的顶部,如果 selected,会执行 select all/unselect all 用于 table 中的所有行(过滤后)。 Vaadin 13 中是否存在这样的解决方案?如果没有,是否有任何(简单且安全的)解决方法来实现类似的目标? (注意:做起来可能比乍看起来有点棘手,因为 select all/unselect 所有复选框应该 select 所有项目 even 如果它们没有被显示,甚至没有在后端缓存中....它应该 select 所有基于过滤条件的记录....)

当您使用内存中没有所有项目的数据提供者时,Grid 默认情况下不会显示“Select all”复选框。这样做的原因是它有可能给大型数据库带来很多麻烦。您仍然可以通过执行以下操作来明确启用它:


import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.Grid.SelectionMode;
import com.vaadin.flow.component.grid.GridMultiSelectionModel;
import com.vaadin.flow.component.grid.GridMultiSelectionModel.SelectAllCheckboxVisibility;

((GridMultiSelectionModel<?>) grid.getSelectionModel())
    .setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility.VISIBLE);

有关详细信息,请参阅 https://github.com/vaadin/vaadin-grid-flow/issues/549