如何使用vaadin检查所有使用复选框的复选框

问题描述:

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

List<Person> 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<Person> 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); 

任何人都可以提出me.how添加这两列通过复选框

+0

答案有帮助吗? –

选择工作与多选择模式,见docs。在同一页面上,您可以阅读有关ComponentRenderer的信息,它允许将任何组件放入列中。请注意,此功能自Vaadin 8.1起可用。前几天发布。