Grails 3-f:table-如何显示相关类的属性 [英] Grails 3 - f:table - how to display property of related class

查看:81
本文介绍了Grails 3-f:table-如何显示相关类的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有2个简单的类:

class Entity{
Integer id
Status status
String type
}

class Status{
Integer id
String name
}

我只需要替换实体列表中状态"字段的表示形式并进行编辑-代替my.appStage:1->正常" 怎么做?

I just need to replace representation of "status" field in Entity list and edit - instead of my.appStage : 1 -> "normal" How to do it?

推荐答案

在以下目录中创建一个名为_displayWrapper.gsp的文件:

Create a file named _displayWrapper.gsp in the following directory:

/views/entity/status

然后在文件中添加以下内容:

Then in the file add the following:

${value.name}

假设您只想打印文本普通".

Assuming you just want to print the text 'normal'.

还有其他方法可以实现此目的,请参见文档.

There are other ways to achieve this, see docs.

问题后更新:

对于f:all,您可以将_wrapper.gsp添加到上述目录,然后添加以下内容:

For f:all you could add _wrapper.gsp to the directory mentioned above and add the following:

<div class="fieldcontain required">
    <label for="status">Status</label>
    <g:select name="status" from="${Status.all}" optionValue="name" optionKey="id" value="${entity?.status}"/>
</div>

这篇关于Grails 3-f:table-如何显示相关类的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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