문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top