当您在 Vaadin v21 中创建 Grid 组件并切换到多选模式时,顶部有一个“全选”复选框。怎么能禁用它?网格的默认行为似乎不同,因此 Vaadin 版本之间的解决方案也不同。
Grid<Person> grid = new Grid<>(Person.class, false);
grid.setSelectionMode(Grid.SelectionMode.MULTI);
grid.setItems(personRepository.findAll());
当您在 Vaadin v21 中创建 Grid 组件并切换到多选模式时,顶部有一个“全选”复选框。怎么能禁用它?网格的默认行为似乎不同,因此 Vaadin 版本之间的解决方案也不同。
Grid<Person> grid = new Grid<>(Person.class, false);
grid.setSelectionMode(Grid.SelectionMode.MULTI);
grid.setItems(personRepository.findAll());
您必须从网格中获取 SlectionModel,才能启用或禁用“全选”复选框:
Grid<Person> grid = new Grid<>(Person.class, false);
grid.setSelectionMode(Grid.SelectionMode.MULTI);
((GridMultiSelectionModel<?>) grid.getSelectionModel())
.setSelectAllCheckboxVisibility(
GridMultiSelectionModel.SelectAllCheckboxVisibility.HIDDEN
);
grid.setItems(personRepository.findAll());