I’m working on a Grails application. There is a domain class “participant” – within the view there is a possibility to select some filters. Those filters get applied through the corresponding controller. Once the filter has been applied to the selection, the result gets posted.
Now the problem is, that I don’t know how to revert those filters or clear them. Obviously, a simple HTML reset button within the view won’t work as the filtered result are POSTed.
Could anyone tell me, how to clear the filters used?
I don’t want a hardcoded href which redirects the user to the normal “list” action.
Any idea(s)?
There are many ways to do what (I think) you want to do. One idea is to create another action in the same controller as the filter action that returns the list you want. I could try to give you an example but from the code you posted it isn’t clear which view you’re coming from, which view should be shown after clearing the filter or where the hardcoded id (1) id coming from. Also, is it possible that the code you posted had been modified in an attempt to solve this? The getParticipants method doesn’t appear to be called at all.
If you wanted to answer some of these questions: starting view, target view (after clearing filters), controller involved and where the id is coming from, I could try to give you a better answer.
Thanks for the extra info. Here’s one possible solution. I didn’t try this so the syntax may not be exact but it’ll get you started:
It looks like what you would get without the filters is all the participants for a Conference. If that’s correct then you can add an action like this to ParcipantController.groovy
Then you can add a tag to your page instead of the hard-coded anchor tag like this:
Clear Filter
I hope that helps,
Dave