根据是否包含值 gsp 更改 grails 行颜色
change grails row color depending on if it contains a value gsp
这个问题与 Is it possible to change table row colour if it contains a certain value in a gsp? 类似,但我不太明白它是否适用于我的场景。
在我的 gsp table 中,如果状态等于 "DOWN",我想将行颜色更改为红色。这是我拥有的:
<g:each in="${compInstanceList}" status="i" var="compInstance">
<tr class="${array.contains(comp.status=="DOWN") ? 'highlightRed' : 'highlightGreen'}">
<td><g:link action="show" id="${compInstance.id}">${fieldValue(bean: compInstance, field: "name")}</g:link></td>
<td>${fieldValue(bean: compInstance, field: "status")}</td>
</tr>
</g:each>
这是我的 css 更改颜色:
.highlightRed{
background-color: red;
}
.highlightGreen{
background-color: green;
}
我确定我的问题出在显示的第二个 gsp 行中。感谢您的帮助。
也许是:
<tr class="${(compInstance.status=="DOWN") ? 'highlightRed' : 'highlightGreen'}">
而不是
<tr class="${array.contains(comp.status=="DOWN") ? 'highlightRed' : 'highlightGreen'}">
这个问题与 Is it possible to change table row colour if it contains a certain value in a gsp? 类似,但我不太明白它是否适用于我的场景。
在我的 gsp table 中,如果状态等于 "DOWN",我想将行颜色更改为红色。这是我拥有的:
<g:each in="${compInstanceList}" status="i" var="compInstance">
<tr class="${array.contains(comp.status=="DOWN") ? 'highlightRed' : 'highlightGreen'}">
<td><g:link action="show" id="${compInstance.id}">${fieldValue(bean: compInstance, field: "name")}</g:link></td>
<td>${fieldValue(bean: compInstance, field: "status")}</td>
</tr>
</g:each>
这是我的 css 更改颜色:
.highlightRed{
background-color: red;
}
.highlightGreen{
background-color: green;
}
我确定我的问题出在显示的第二个 gsp 行中。感谢您的帮助。
也许是:
<tr class="${(compInstance.status=="DOWN") ? 'highlightRed' : 'highlightGreen'}">
而不是
<tr class="${array.contains(comp.status=="DOWN") ? 'highlightRed' : 'highlightGreen'}">