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

Re: list.gsp with filter and pagination

by Pascal DeMilly-4 :: Rate this Message:

Reply to Author | View in Thread

(resent because of slippery fingers :-)

Thanks Daniel. I had tried that with sortableColumn when I read the code in
RenderTagLib that used attr.params like that:

<g:sortableColumn property="description" title="Description"
params="$params" />

but got an error

groovy.lang.MissingMethodException: No signature of method:
java.util.LinkedHashMap.putAll() is applicable for argument types:
(org.codehaus.groovy.runtime.GStringImpl) values:
{["max":20, "action":"list", "controller":"item"]}
        at
home_pdemilly_NetBeansProjects_grails_test_5_grails_app_views_item_list_gsp.run(home_pdemilly_NetBeansProjects_grails_test_5_grails_app_views_item_list_gsp:47)
list: ["max":20, "action":"list", "controller":"item"]

How would you pass that attributes then? How do you specify a map in GSP?

In the meantime I recreated my own paginate which put the filter value in the
linkParams and that works. Now I am working on the sorting.

Thanks

Pascal




On Friday 15 August 2008 12:55:03 am Daniel J. Lauk wrote:

> Add the params attribute to the paginate tag.
>
> Cheers,
> DJ
>
> Pascal Demilly wrote:
> > 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

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

    http://xircles.codehaus.org/manage_email


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