Reputation: 6095
Lets say I have an Issues domain class and it has as a field assignedTo:
String title
String priority
User assignedTo
...
I need to be able to sort on assignedTo. Neither the list.gsp default scaffolding nor the tag it uses, g:sortableColumn, support this. It seems like the g:sortableColumn needs to have both a property field, and a propertyOfProperty field.
Do you know a good way to solve this?
Upvotes: 4
Views: 2754
Reputation: 1764
Ray's solution will work but if assignedTo is a nullable field, any results with assignedTo set as null won't show up in your result list
This grail's solution is a workaround: http://www.grails.org/version/GSP+Tag+-+sortableColumn/2
Of course if it is a required field, or you don't care about not showing results without the assignedTo variable then use property="assignedTo.lastName"
Upvotes: 1
Reputation: 6095
Ok, so this appears possible, just missing clarity in the documentation, and searching the web didn't help.
So, one can do property="assignedTo.lastName", i.e.
<g:sortableColumn property="assignedTo.lastName" title="${message(code: 'issue.assignedTo.label', default: 'Assigned To')}" />
Upvotes: 1