-1

How do i load records to a Grails combo-box (look screenshot below).

enter image description here

def bookList = Book.getAll();

Now how do i display the above book list in a Combo box?

tim_yates
  • 167,322
  • 27
  • 342
  • 338
Illep
  • 16,375
  • 46
  • 171
  • 302

1 Answers1

0

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" />
Joshua Moore
  • 24,706
  • 6
  • 50
  • 73