使用脚手架开发用于访问资源的简单 CRUD。
我有一张 table
ResourceType:
{
Name
}
Example: Developer, Manager, Director
我有一张 table
Resource:
{
Name,
ResourceType resourcetype
}
Example: Bob Jones of type Develper. Grace Smith of type Manager
我有定义工作以获取在 Web 界面上显示数据的关系:
资源类型:
名称、资源 ID
问题是我得到:
Bob Jones, 0
Grace Smith, 1
Alex Rodgers, 1
我想让 View 显示来自 ResourceType 的名称:
Bob Jones, Developer
Grace Smith, Manager
Alex Rodgers, Manager
此外,对于新数据条目,下拉列表应列出来自 ResourceType 的名称,而不是 Id。
最佳答案
覆盖 ResourceType
的 toString() 方法可能有帮助。
String toString() {
Name
}
关于Grails - ORM 加入以显示名称与 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9387401/