sysbeast
sysbeast

Reputation: 275

Using a Grails "g:sortableColumn" to sort by the size of a "hasMany" (many to one) property?

is it possible to use the Grails "g:sortableColumn" tag to sort by a domain class "hasMany" property count?

class Book { hasMany = [authors: User]}

I want to sort all Books by the number of authors with a "g:sortableColumn" tag in my view, but how? Realy not possible?

Thanks and best regards...

Upvotes: 3

Views: 820

Answers (1)

Aaron Saunders
Aaron Saunders

Reputation: 33335

not the best solution, but one

http://www.pubbs.net/200904/grails/65695-grails-user-sort-by-one-to-many-count-with-gorm-or-criteria.html

I thought there was a way to do it with criteriaBuilder but I cannot seem to make it work without changing your domain object

Upvotes: 1

Related Questions