如何使用vaadin中的标题复选框选中所有复选框 [英] How to check all checkboxes usingheader checkbox in vaadin

查看:166
本文介绍了如何使用vaadin中的标题复选框选中所有复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Ia m new to vVadin. I created one project with grid with two columns but i want to add one Textfield column and one checkbox column and check all checkboxes when click on header checkbox.

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

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

can anyone suggest me.how to add those two columns

推荐答案

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

Selection via check boxes works with the multi selection mode, see docs. On the same page you can read about ComponentRenderer which allows to put any component in a column. Note that this feature is available since Vaadin 8.1. released few days ago.

这篇关于如何使用vaadin中的标题复选框选中所有复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆