带有默认选项的可编辑组合框

Vaadin Editable ComboBox with default options

本文关键字:编辑 组合 默认 选项      更新时间:2023-09-26

我是新的Vaadin开发人员,我有一个小问题,我希望能在这里解决。

实际上我有一个组合框与一些数据与一个过滤器找到一些匹配,所以…我需要在组合框中输入需要的用户的新值。问题是我不能输入新值,因为当我这样做时,我的过滤器正在删除我的新提案。

我的代码…

    //Select select_editable = new Select();
    ComboBox cbEducation = new ComboBox();
    cbEducation.setTextInputAllowed(true);
    cbEducation.setNewItemsAllowed(true);
    cbEducation.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    //Fill the component with some items.
    for (int i = 0; i < planets.length; i++)
        for (int j = 0; j < planets.length; j++) {
            cbEducation.addItem(planets[j] + " to " + planets[i]);
        }
    //select_editable.
    mainLayout.addComponent(cbEducation, 1, 0);
    mainLayout.setComponentAlignment(cbEducation, new Alignment(33));

我希望有人能帮助我…无论如何,感谢阅读

提前感谢!

如果你想在输入后立即看到新输入的值,你必须将组合框的immediate模式设置为true。

cbEducation.setImmediate(true);

如果你使用VisualDesigner来创建你的布局,要小心。它会将所有组件的即时状态设置为false。