« Return to Thread: list.gsp with filter and pagination

list.gsp with filter and pagination

by Pascal DeMilly-4 :: Rate this Message:

Reply to Author | View in Thread

Hi,

I am trying to add a search filter (based on the definite guide to Grails) to
one of my list.gsp.

    def search = {
            if (params?.search == 'clear') {
                    params.filter = ''
            }
            redirect (view: list, params: params)
    }

   def list = {
        def items

        if(!params.max) params.max = 20
        if (params?.filter) {
            def criteria = Item.createCriteria()
            items = criteria.list(params) {
                or {
                        ilike ('sku', "%${params.filter}%")
                        ilike ('description', "%${params.filter}%")
                        ilike ('model', "%${params.filter}%")
                        ilike ('primaryVendor', "%${params.filter}%")
                }
            }
        }
        else
            items = Item.list (params)

        render (view: 'list', model: [ itemList: items, filter:
params.filter ], params: params)
    }

The problem is that when the user press the pagination, the filter is lost.
How can I access the view model from the controller or how can I make the
pagination to remember the filter value

TIA

Pascal

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: list.gsp with filter and pagination