jQuery UI autocomplete with item and id

前端 未结 11 1805
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 00:32

I have the following script which works with a 1 dimensional array. Is it possible to get this to work with a 2 dimensional array? Then whichever item is selected, by clic

11条回答
  •  隐瞒了意图╮
    2020-11-29 00:56

    At last i did it Thanks alot friends, and a special thanks to Mr https://stackoverflow.com/users/87015/salman-a because of his code i was able to solve it properly. finally my code is looking like this as i am using groovy grails i hope this will help somebody there.. Thanks alot

    html code looks like this in my gsp page

      
      
    

    script Function is like this in my gsp page

      
    

    And my controller code is like this

       def autoCOmp(){
        println(params)
        def c = Client.createCriteria()
        def results = c.list {
            like("nameOfClient", params.inputField+"%")
        }
    
        def itemList = []
        results.each{
            itemList  << [value:it.id,label:it.nameOfClient]
        }
        println(itemList)
        render itemList as JSON
    }
    

    One more thing i have not set id field hidden because at first i was checking that i am getting the exact id , you can keep it hidden just put type=hidden instead of text for second input item in html

    Thanks !

提交回复
热议问题