Group By Unidirection with GORM
문제
I have a fairly common pair of models:
class Parent {
static hasMany = [children: Child]
}
class Child {
String someProperty
}
Now what I'm trying to do is perform a group by Child.someProperty, but I haven't been too successful on View.
In the controller, I can do:
def children = parentInstance.children.groupBy{child -> child.someProperty}
What I'm trying to achieve is recursively display children under each someProperty
.
해결책
I ended up solving my own problem. I simplified the functionality by simply adding a method to the Parent model to return all children with the relative Parent id or instance sorted by the desired property.
제휴하지 않습니다 StackOverflow