Search code examples
grailsgrails-orm

how can set where condition in list() method in grails


I am using list() method to get the data.

<g:select id="complaint" class="form-control chosen-select" multiple="true" name="complaint" from="${settings.Complaint.list()}"optionKey="id" optionValue="name"/>

Now I would like get the data as list which status is active. Is there any way to use condition in list()?


Solution

  • def c = vaccination.VaccineBrand.createCriteria()
        def vaccineBrandList = c.list {
            eq("status", "Active")
        }