简体   繁体   中英

Grails Pagination in a search query page

I am using following query to filter results in grails.

userList = SecUser.all.findAll{it.merchants.findAll {it.name.toLowerCase()=~ searchString.toLowerCase()}.size()>0}

In this code i have Users and each User have multiple merchants. I extract only that user whose merchant name matches a certain pattern.

Now i further have to filter these users on:

params.max
params.offset 

So that i can perform pagination on them. Kindly please help me with this problem.

This has not been tested, but try something like this:

def query = SecUser.where {
    merchants.any { merchant ->
        merchant.name.equalsIgnoreCase( searchString )
    }
}
def userList = query.findAll(max: params.max, offset: params.offset)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM