如何显示复选框而不是在vaadin网格中的布尔值? [英] How to display checkboxes instead of boolean in vaadin grid?

查看:102
本文介绍了如何显示复选框而不是在vaadin网格中的布尔值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的布尔值显示为vaadin网格中的复选框.我无法使用多选模式,因为我需要两列带有复选框. Checkboxes外壳程序的列具有标题,但Checkboxes本身的外壳没有标题.有人有主意吗?

I'm trying to display my boolean values as a checkbox in a vaadin grid. I can't use the multi selection mode because i need two columns with checkboxes. The columns of the Checkboxes shell have a Caption but the Checkboxes itself shell be without a caption. Does anyone have an idea ?

推荐答案

您必须为复选框添加生成的列

You have to add generated columns for your checkboxes

    GeneratedPropertyContainer gpcontainer = new GeneratedPropertyContainer(container);
    gpcontainer.addGeneratedProperty("columnName",
        new PropertyValueGenerator<CheckBox>() {
        @Override
        public CheckBox getValue(Item item, Object itemId,
                                Object propertyId) {

            // set checkBox listener etc. in here
            return new CheckBox();
        }

        @Override
        public Class<CheckBox> getType() {
            return CheckBox.class;
        }
    });

Grid grid = new Grid(gpcontainer);

您可以在此处的"GeneratedPropertyContainer"部分中找到更详细的示例

You can find more detailed example in here in section "GeneratedPropertyContainer"

https://vaadin .com/docs/-/part/framework/datamodel/datamodel-container.html#datamodel.container.gpc

还要为您的列设置"ComponentRenderer"

Also set `ComponentRenderer' for your column

mainGrid.addColumn(COLUMN).setRenderer(new ComponentRenderer())

这篇关于如何显示复选框而不是在vaadin网格中的布尔值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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