Quantcast

Is it possible to programatically add search constraints to filterpane?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Is it possible to programatically add search constraints to filterpane?

gatherer
Is it possible to add search constraints to the filterPaneService.filter(...) call in the filterPane action? Let's say the user wants to filter a list of Books by author in the filterPane dialog but I, the programmer, want to futher limit the results because I don't want to show the books that are marked as "hidden", and obviously the user is not going to mark this constraint in the filterpane dialog and I don't want to expose it.

In other words, the user wants a Book.findAllByAuthor('name') and I want to give him Book.findAllByAuthorAndHidden('name', false) . But filterPane has to handle all this restrictions.

I could just execute the filter call and get all the books filtered by author, and then go thru the list and discard the hidden ones, but I would like the filterPane service quickly to do everything in its DB query.

If it is not possible or there's no clean and efficient workaround, it would be nice to have this functionality added to the plugin.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Is it possible to programatically add search constraints to filterpane?

skrenek
Yes, this is possible, but there is no built-in support for it yet in the plugin.  You will want to add a couple parameters to the map you pass to the filter service.  I do this now for creating pre-configured links to filtered content (another tag I need to add to the plugin).  For the example you used below, the following parameters should work for you.

[ 'filter.op.hidden' : 'Equal', 'filter.hidden' : true ]

There is already a JIRA ticket for adding a static filter feature, which should cover the functionality that you want.  See http://jira.grails.org/browse/GPFILTERPANE-34

If the sample parameters don't work for you, or you need further assistance, let me know.

Cheers,
Steve

On Fri, Aug 12, 2011 at 8:02 AM, gatherer <[hidden email]> wrote:
Is it possible to add search constraints to the filterPaneService.filter(...)
call in the filterPane action? Let's say the user wants to filter a list of
Books by author in the filterPane dialog but I, the programmer, want to
futher limit the results because I don't want to show the books that are
marked as "hidden", and obviously the user is not going to mark this
constraint in the filterpane dialog and I don't want to expose it.

In other words, the user wants a Book.findAllByAuthor('name') and I want to
give him Book.findAllByAuthorAndHidden('name', false) . But filterPane has
to handle all this restrictions.

I could just execute the filter call and get all the books filtered by
author, and then go thru the list and discard the hidden ones, but I would
like the filterPane service quickly to do everything in its DB query.

If it is not possible or there's no clean and efficient workaround, it would
be nice to have this functionality added to the plugin.

--
View this message in context: http://grails.1312388.n4.nabble.com/Is-it-possible-to-programatically-add-search-constraints-to-filterpane-tp3739172p3739172.html
Sent from the Grails - user mailing list archive at Nabble.com.

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

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Is it possible to programatically add search constraints to filterpane?

gatherer
Thx Steve, it works great.

Another question, is there a way to pass params to the filterPane action? I can't find in the docs, in the filterPane tag description I can only find how to change the default action.
Loading...