0

I have created cascading select as follows-

<td>Reference Table:</td>
<td><g:select name="tableCombo"
            noSelection="${['':message(code:'Select Table')]}"
            from="${result}" value="${tableName }"     onchange="${remoteFunction(controller:'load',
             action:'getColumns', update:'columns', params:'\'tableCombo=\' + this.value')}"/></td>
    </tr>
    <tr><td>Constraint On 1:</td>
        <td><g:select name="columns" noSelection="${['':message(code:'Select Columns')]}" from="[]" /></td>
        <td>Constraint Value :
        </td>
        <td><g:textField name="columnValue" value="${enterVal }"     />   </td> </tr>
<tr><td>Constraint On 2:</td>
        <td><g:select name="columns2" noSelection="${['':message(code:'Select Columns')]}" from="[]" /></td>
        <td>Constraint Value :</td>
        <td><g:textField name="columnValue" value="${enterVal }" />   

NOW i want to render and populate columns & columns2 both select box onchange tableCombo. but dont know how to render both from controller.

def getColumns = {
    def columns = GGWSchemaXref.executeQuery("select distinct p.columnname     from GGWSchemaXref p where p.tablename=:table",[table:params.tableCombo])
    render g.select(from:columns, name:"columns")
        }

PLEASE HELP ON THIS.

thanks

sana
  • 460
  • 1
  • 10
  • 25
  • thanks for reply Alidad. you are right i want to update two select boxes (at a time) when first selectbox changes. can i specify column & column2 both in update anyway (below) onchange="${remoteFunction(controller:'load', action:'getColumns', update:'columns', params:'\'tableCombo=\' + this.value')}"/> I have used the template way. – sana Mar 18 '12 at 12:03
  • I dont think you can update more than one elements with "update". based on this jira http://jira.grails.org/browse/GRAILS-4878. but you can write a javascript function to update the elements based on the response. instead of rendering your select from controller, return the required values in a map or in JSON then render them using javascript. – Alidad Mar 18 '12 at 23:58

1 Answers1

0

It seems that you are trying to populate the value of your two selects based on the value of the first select. I would suggest to return a JSON or render a template including a modal map including your result from your controller and render it on your views. Take a look at these two questions:

how to populate 2nd Combobox(g:select) values on basis of 1st Combobox (g:select)

Grails: Load data on one ComboBox depending on another

hope these helps

Community
  • 1
  • 1
Alidad
  • 5,463
  • 1
  • 24
  • 47
  • thanks Alidad. above both links are doing the same thing which i tried.My problem is how to pass two selectbox(at a time) name while update after calling remotefunction? – sana Mar 18 '12 at 13:40