2017-05-08 38 views
0

数据不是由克检索:选择Grails中3. 我的代码是像如下─数据不是检索由G:选择Grails中3

<g:select from="${Machine_summaryList}" name="brand" /> 

这里“Machine_summaryList”是“Machine_summary”的列表类和“品牌”是我需要检索的数据列。

+0

和问题是什么? – injecteer

+0

这里所有的品牌名称都应该选择,但数据不能检索 –

+0

你怎么知道? mayby你的清单是空的? – injecteer

回答

0

就在这个过程对我的作品

<g:select from="${project.Machine_summary.executeQuery("select distinct c.brand from Machine_summary c")}" name="brand" /> 
1

在这种情况下,您需要使用optionValue="brand"

g:select必须像:

<g:select from="${Machine_summaryList}" name="brand" optionKey="id" optionValue="brand"/> 

当表单将提交,你会在params.brand收到所选择的机器。

+0

我也使用过这一个,但它不工作,而我有Machine_summaryList中的数据,它通过使用“$ {Machine_summaryList}”抛出List.gsp中的数据,但它的不在g:select上工作 –