如何使用vaadin中的标题复选框选中所有复选框

我是vVadin的新手。 我创建了一个带有两列网格的项目,但我想添加一个Textfield列和一个复选框列,并在单击标题复选框时选中所有复选框。

List people = Arrays.asList( new Person("Nicolaus Copernicus", 15), new Person("Galileo Galilei", 15), new Person("Johannes Kepler", 15)); TextField txt =new TextField(); CheckBox chk=new CheckBox(); // Create a grid bound to the list Grid grid = new Grid(); grid.setItems(people); grid.addColumn(Person::getName).setCaption("Name"); grid.addColumn(Person::getAge).setCaption("Year of birth"); grid.addColumn(Person-> new TextField()); layout.addComponents(grid); setParent(layout); 

任何人都可以建议我。如何添加这两列

通过复选框选择适用于多选模式,请参阅文档 。 在同一页面上,您可以阅读ComponentRenderer ,它允许将任何组件放入列中。 请注意,此function自Vaadin 8.1起可用。 几天前发布。