在grails GSP中,我正在做一些类似的事情
<g:each in="${testInstance?.testConfigs?}" var="t">
有两类
class Test{
static hasMany = [testConfigs:TestConfig]
}
class TestConfig {
Date dateCreated
Date lastUpdated
Test test
static constraints = {
dateCreated display:false
lastUpdated display:false
questionType inList:["Fill in the blanks","Multipl choice","True False"]
}
}
如何更改for each循环,以便按dateCreated字段降序检索testConfigs对象?
像文档中所说的那样定义排序顺序不起作用吗?
class Test{
static hasMany = [testConfigs:TestConfig]
static mapping = {
testConfigs sort: 'dateCreated', order: 'desc'
}
}