Vaadin 网格 - gridpro 组合框编辑器
Grid Pro 具有三个推荐的内置编辑器:文本字段、复选框和选择。 您可以管理具有键和值属性的列表吗? 例如: 国家/地区列表
我无法在选择中显示国家/地区名称值并将 id 保存在数据库记录中。 当我管理带有键和值的列表时,我通常依赖 ComboBox。 组合框不存在于内置编辑器列表中。 您建议编写自己的编辑器吗?
Grid Pro features three recommended built-in editors: Text Field, Checkbox, and Select.
Ho can you manage a list with key and value properties?
For example:
Country list
I'm unable to show country name in the select value and save the id in the database record.
I usually rely on ComboBox when I manage a list with key and value.
Combobox is not present in the list of built-in editors.
Do you suggest to write your own editor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让我们假设您有一个
country
具有属性ID
和名称
的类。和Person
country
属性的类。您显示gridpro< person>
。您可以制作
选择
编辑器并定义其是itemlabelgenerator(或者,如果要显示标志或其他内容)以显示country :: getName
。 **The saving to the database should be handled by the annotations on the relation.通常使用JPA,人与国家之间会有@manytoone的关系,并将其保存在人表中的国家 /地区(ID,使用@ID指定)。
**我不使用GRID PRO,但是在检查代码后,我可以通过使用
gridpro.addeditcolumn(Person :: GetCountry)。Select(Person :: SetCountry,code)
您无法指定itemLabelgenerator/Renderer。但是,您可以准备自己的
选择
组件,并使用editcolumnconfigurator :: custom
方法。Let's assume you have a
Country
class with the propertiesid
andname
. And aPerson
class with acountry
property. You display aGridPro<Person>
.You can make a
Select
editor and define it's itemLabelGenerator (or renderer, if you want to show a flag or something) to showCountry::getName
. **The saving to the database should be handled by the annotations on the relation. Usually using JPA, there would be a @ManyToOne relation between Person and Country, and save the country-FK (id, specified using @Id) in the person table.
** I don't use Grid Pro, but upon inspection of the code I can see that by using
gridPro.addEditColumn(Person::getCountry).select(Person::setCountry, countriesList)
you cannot specify the itemLabelGenerator/renderer.However, you could prepare your own
Select
component and use theEditColumnConfigurator::custom
method.