1
votes

Given the grails dynamic method list() on a domain class, how does one control the appearance of the list elements, but NOT using the toString() method. I.e. in one case I need the list returned to look one way (in my g:select), and in another case, I need it to look another way, from the same domain class, as it is using different fields.

Thanks

2

2 Answers

2
votes

It looks like one can also do a closure in the optionValue part of g:select, e.g.

<g:select optionKey="id" optionValue="${{it.title?.toUpperCase()}}" name="book.title" from="${bookList}" />

I missed this before.

0
votes

Pass a list of DTOs to your GSP instead of a list of your domain objects. Format the DTOs however you need them to be.