简体   繁体   中英

How can I customize grails select tag

I want to customize grails select tag

I tried this code

 <g:select name="totalHour" from="${1..20}" value="${holdingVacationInstance}"/> 

this code select options look like this

1, 2, 3, ... , 20

then, how can i make like this

0.5, 1.0, 1.5, ... , 20.0

Using the 'from' attribute you'll either have to give the select options as a list or as a Groovy Range.

IMO the latter is a more solid way to go:

Groovy range with a 0.5 step size

You can use like this

<g:select name="totalHour" from="${(0.5..20).step(1)}" value="${holdingVacationInstance}"/>

Then it will give output like [0.5, 1.5, 2.5, 3.5, ...] as per my concern you can't use non integer step. See here http://grails.asia/groovy-range-examples

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM