2017-05-08 22 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上工作 –