【发布时间】:2013-09-29 13:46:08
【问题描述】:
我是 grails 的新手...
我想为我的 jquery 自动完成创建一个控制器
def arrSong = Song.executeQuery("select id, title as value, concat(artist, ' - ', title) as label from ${Song.name} where title like concat('%', :paramTitle, '%')", [paramTitle:params.term?.toString()])
render arrSong as JSON
通过这段代码我得到了这个 JSON:
[[1,"Mr. Brightside","The Killers - Mr. Brightside"]]
我的期望是这样的:
[{"id":1,"value":"Mr. Brightside","label":"The Killers - Mr. Brightside"}]
有人可以帮忙吗?
【问题讨论】:
-
看看 ajaxdependancyselection 插件。它提供来自 gsp 的自动完成功能