user82302124
user82302124

Reputation: 1143

Grails - remoteField with additional parameters (3 parameters, no id work around)

In a work around I've used in the past, I've used the id field to pass an additional parameter that I needed. But I need to pass three parameters through a remoteField and now am presented with the fact I need to find a way to pass these parameters:

<g:remoteField action="updateFields" update="theDiv" id-"${personInstance.id}" paramName="search" name="updateFields" value="" />

Need: The search field (search), the person id (id), and now I need the company the person works for (c_id).

I can do something like this:

<g:remoteField action="updateFields" update="theDiv" id-"${personInstance.id}" paramName="search" name="updateFields" value="" params="${[c_id:c_id, search:/'+this.value+/']}"/>

If I try to obtain the search value with the params, the search field is now '+this.value+'. Can I just pass the object search field as an addition param in the map (like above) by referencing this.value? If so, what am I doing wrong, since my gsp doesn't load.

Edit

My current work around is to tie both IDs in a ID field, split by a delimiter and then broken into an array once it reaches the controller (obviously not ideal!)

Upvotes: 0

Views: 642

Answers (1)

David Brown
David Brown

Reputation: 3061

Although I don't use remoteField, I do use remoteFunction frequently and have found I can use multiple javascript based variables directly with the 'params' parameter. E.g.

<script>
  function someJSFunction(id1,id2,id3) {
     <g:remoteFunction action="ajax_function" params="{id1:id1,id2:id2,id3:id3}" update="someDiv"/>
  }
</script>

Hope that helps.

Upvotes: 1

Related Questions