Grails 脚手架显示的列数少于域
我的域类中有 6 列。但当脚手架设置为 true 时,我在控制器列表上只看到 5 列。 我的数据库是mySql。当使用正确的列数创建执行表时 我的域类
class RouteDesc {
String routenumber
String routeoperator
String routeinstructions
Date validfrom
Date validto
String weekendavailablity
static constraints = {
routenumber blank:false, unique:true, display:true
routeoperator blank:false, display:true
routeinstructions blank:true, display:true
validfrom display:true
validto display:true
weekendavailablity display:true
}
//static belongs to = RouteId
String toString () {
return routenumber
}
}
我的控制器类
class RouteDescController {
static scaffold = true
}
I have 6 columns in my domain class. But i only see 5 columns on the controller list when scaffold is set to true.
My database is mySql. When executed table is created with correct number of columns
My domain class
class RouteDesc {
String routenumber
String routeoperator
String routeinstructions
Date validfrom
Date validto
String weekendavailablity
static constraints = {
routenumber blank:false, unique:true, display:true
routeoperator blank:false, display:true
routeinstructions blank:true, display:true
validfrom display:true
validto display:true
weekendavailablity display:true
}
//static belongs to = RouteId
String toString () {
return routenumber
}
}
My Controller class
class RouteDescController {
static scaffold = true
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认的脚手架列表页面将列数限制为 6(因为eachWithIndex 是从零开始的),其中 1 个将用于 ID 列,因此仅显示 5 个属性。如果您想更改此设置,可以通过
grails install-templates
安装模板(在 Grails 2.0 中),该模板会将模板放置在src/templates/scaffolding/
下。您需要更新的模板是 list.gsp,大约中间有以下代码:您需要将 6 更改为您想要的任何内容。附带说明一下,字段通过脚手架出现的顺序可以通过它们在约束中定义的顺序来控制( http://grails.org/doc/latest/guide/scaffolding.html)。
The default scaffolding list page limits the number of columns to 6 (since eachWithIndex is zero based) and 1 of them will be used for the ID column so only 5 attributes will show. If you'd like to change this you can install templates via
grails install-templates
which (in Grails 2.0) will place the templates undersrc/templates/scaffolding/
. The template you'd need to update is the list.gsp about half way down there is the following code:You'd need to change that 6 to whatever you want it to be. As a side note the order that fields appear through scaffolding can be controlled by the order in which they are defined in the constraints ( http://grails.org/doc/latest/guide/scaffolding.html).
贾里德·奥尔森建议的又一补充
}
也改变
One more addition to what Jarred Olson suggested
}
Also change