[英]grails g:select tag
I am using ag:select tag like this: 我正在使用ag:select标签,如下所示:
<td><g:select name="newCity"
id="${'newCity_' +cityData.uid}"
from="${cityData.name}"
value="${cityData.someValue}"
noSelection="${['null':'Select City...']}" class="newCity" />
</td>
which renders the following HTML: 它呈现以下HTML:
<td>
<select name="newCity" id="newCity_abc" class="newCity" >
<option value="null">Select City...</option>
<option value="A" >A</option>
<option value="B" >B</option>
<option value="C" >C-</option>
<option value="D" >D</option>
</select>
</td>
However, I want my HTML to look like this; 但是,我希望我的HTML看起来像这样; with class inserted since I am doing some javascript validation:
因为我正在做一些javascript验证,所以插入了类:
<td>
<select name="newCity" id="newCity_abc" class="newCity" >
<option value="null">Select City...</option>
<option value="A" class="populated" >A</option>
<option value="B" class="notpopulated" >B</option>
<option value="C" class="populated" >C</option>
<option value="D" class="notpopulated" >D</option>
</select>
</td>
Is this possible? 这可能吗?
Do I need to create a custom tag library to acheive this? 我是否需要创建自定义标记库才能实现此目的?
Any help will be appreciated, Thanks! 任何帮助将不胜感激,谢谢!
I don't believe this is possible. 我不相信这是可能的。 The select tag implementation (which writes out the
<option>
tags ) calls the private method writeValueAndCheckIfSelected
to fill in the option
, and this is not aware of any class names. select标记实现 ( 写出
<option>
标记 )调用私有方法writeValueAndCheckIfSelected
来填充option
,这不知道任何类名。
There is a 2 year old New Feature Request on the Grails JIRA , but I think you may be stuck rolling your own tag to do this for your specific situation. Grails JIRA上有一个2年的新功能请求 ,但我认为您可能会因为特定情况而无法使用自己的标签来执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.