I have written a domain class and scaffolded the controller and the views. I’ve modified the list.gsp and list action a bit. To filter what’s displayed, I’ve put a g:select tag on the page.
Whenever the value in the select is changed, the list controller is fired again and filters the data instance returned. This works like a charm.
Thing is that I can’t display the changed instance; the only way I know to update the GSP is to do a window.location.reload() but that results in a re-initialization of the page. So everything is back to default.
So here is the question: how can I make my GSP pick up the changed instance data and display that?
For example, one of the selects. The returned instance is filtered though the selected month and year variables.
<g:select id="monthSelection" from="${['Jan', 'Feb', 'Mrt', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec']}" value="${inputYear}" onchange="${remoteFunction(
action:'list',
params:'\'selectedYear=\' + escape(yearSelection.value) +\'&selectedMonth=\' + escape(this.value)'
)}"
"/>
Thanks!
Sounds like you either need to
remoteFunctionmethod so that it returns a template view, and set theupdateparameter on theremoteFunctioncall to specify which div on the page should get dynamically updated with the content from the returned view.I’ve used option 2 in several cases where I needed an ajax update and it worked nicely.