How do i load records to a Grails combo-box (look screenshot below).
def bookList = Book.getAll();
Now how do i display the above book list in a Combo box?
This is trivial to do once you have the bookList
in your model for your GSP.
Assuming a controller action something like this:
class MyController {
def index() {
def bookList = Book.getAll()
render(view: 'index', model: [bookList: bookList])
}
}
And a domain like this:
class Book {
String title
}
You can render it using the g:select tag in your GSP like this:
<g:select from="${bookList}" optionKey="id" optionValue="title" />