Groovy / Grails – 需要检索List索引值
发布时间:2020-12-14 16:28:45 所属栏目:大数据 来源:网络整理
导读:我需要检索列表中每个值的索引位置.我正在这样做,以便我可以显示具有交替行背景颜色的gsp表.例如: (list.indexVal % 2) == 1 ? 'odd' : 'even' 如何获取Groovy列表中每个项目的索引位置编号?谢谢! 解决方法 According the documentation,g:gsp视图中的每
我需要检索列表中每个值的索引位置.我正在这样做,以便我可以显示具有交替行背景颜色的gsp表.例如:
(list.indexVal % 2) == 1 ? 'odd' : 'even' 如何获取Groovy列表中每个项目的索引位置编号?谢谢! 解决方法
According the documentation,g:gsp视图中的每个标记都允许“status”变量
其中grails存储迭代索引. 例: <tbody> <g:each status="i" in="${itemList}" var="item"> <!-- Alternate CSS classes for the rows. --> <tr class="${ (i % 2) == 0 ? 'a' : 'b'}"> <td>${item.id?.encodeAsHTML()}</td> <td>${item.parentId?.encodeAsHTML()}</td> <td>${item.type?.encodeAsHTML()}</td> <td>${item.status?.encodeAsHTML()}</td> </tr> </g:each> </tbody> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |