我是新的 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));
我希望有人能帮助我......无论如何,感谢您的阅读
提前致谢!
最佳答案
如果您想在输入后立即看到新输入的值,则必须将组合框立即模式设置为 true。
cbEducation.setImmediate(true);
如果您使用 VisualDesigner 创建布局,请务必小心。它将所有组件的即时状态设置为 false。希望这个不错的工具很快就会得到更新。
关于java - 具有默认选项的 Vaadin 可编辑组合框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25359786/