There are two ways to edit the drop-down list:
1. By overriding the toString function of the domain
class Student {Without touching the GSPs, the drop-down list will show the first names and last names of the students and not the default package.domain : id (e.g. Student : 1)
String firstName
String lastName
String toString(){
StringBuilder sb = new StringBuilder()
sb.append(firstName)
sb.append(" ")
sb.append(lastName)
return sb.toString()
}
}
2. By setting the attribute optionValue in g:select tag
optionValue="firstName"will show only the first names of the students. If you want to show the first names and last names, you may opt to use
optionValue="${{it.firstName + ' ' + it.lastName}}"Note that character/s can be inserted for each iteration inside single quotes.
great!
ReplyDeleteThanks! I was struggling with this. It is not clear in the docs or examples how to control the ddl without writing a custom view
ReplyDelete