简体   繁体   English

更改Grails Domain Class的显示名称

[英]Change display name of Grails Domain Class

I have a one-to-one relationship, and have a combobox for selecting the other one. 我有一对一的关系,并有一个组合框用于选择另一个。 How do I change the display name of the combo box? 如何更改组合框的显示名称?

Here's a screenshot of the combo box, to make myself clear: 这是组合框的截图,让我自己清楚: cmb box的屏幕截图

I'm new to grails, and are attempting to create a simple data-driven app for in house use. 我是grails的新手,并且正在尝试创建一个简单的数据驱动应用程序供内部使用。

Edit: My toString(): 编辑:我的toString():

  def toString = { "${naam} [${gemeente}]" }

Override the toString method of said domain class. 覆盖所述域类的toString方法。

String toString() {
    return this.name;
}

In Grails 3, the following works: 在Grails 3中,以下工作:

String toString() {
  return "${name}"
}

in your example, this would be: 在您的示例中,这将是:

String toString() {
  return "${naam} [${gemeente}]"
}

cheers! 干杯!

sig需要是String toString() { ... } (你返回一个def,它是一个闭包,而不是一个方法)

在grails中,select标签还有一个名为“optionValue”的可选属性,允许您定义要显示的bean字段/属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM