如何在grails控制器中获得级联结果

时间:2016-11-16 11:26:22

标签: javascript jquery ajax grails cascading

您好我在grails中使用3个参数,像乡村,城市,街道一样工作 它们是级联的......街道的价值取决于城市和城市取决于国家。

但是我无法在参数City中的参数country中选择值。

这是Controller

中参数country的代码
def getCountryList(){
        def vListCountry = domaindata.findAllByCountryIlike(params.pattern+"%")


        render g.select(id:'businessP', name:'businessP.id',
            from:vListCountry, optionKey:'id', required:'true', optionValue:'Country',noSelection:['':' Select Country...' ],class:'form-control'
           )
            }

这是City的代码

def getCityList(){


        def vListCity = domaindata.findAllByCityIlike(params.pattern+"%")

            render g.select(id:'businessP', name:'businessP.id',
                from:vListCity, optionKey:'id', onchange:'getCountryList();', required:'true', optionValue:'city',noSelection:['':' Select City...' ],class:'form-control'
               )

    }

或者我可以使用Jquery吗?

 def getZipList(){
render g.select(id:'zipCode', name:'zipCode.id',
                from:zipCode, noSelection:['':' Select Zip...' ],class:'form-control'
               )
}

并在gsp页面的下拉列表中进行了

0 个答案:

没有答案