grails - 如果表行颜色在gsp中包含某个值,是否可以更改表行颜色?

标签 grails groovy styling gsp

我在gsp中有一个包含10个deiiferent值的表:

<table class="table table-striped">
<tr>
    <th scope="row">Name:</th>
    <td>
        ${person.name}
    </td>
</tr>
<tr>
    <th scope="row">Address:</th>
    <td>
        ${person.address}
    </td>
</tr>............

我需要突出显示(如果某些值存在于gsp中可用的数组中,请更改某些值的背景或文本格式。

这可能吗?例如使用g:if?喜欢 :
  <tr>
    <th scope="row">Name:</th>
    <td>
               <g:if ${array}.contains("${person.name}")>
        //change styling of this cell
                   ${person.name}
                </g:if>
    </td>
</tr>

最佳答案

这应该可以,但是我还没有尝试过:

<td class="${array.contains( person.name ) ? 'highlight' : ''}">

因此,如果包含名称,则将“highlight”类添加到td

关于grails - 如果表行颜色在gsp中包含某个值,是否可以更改表行颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16567114/

相关文章:

grails - 服务器端推送(竞争)以填充完整的Calendar事件,而无需在Grails中进行javascript轮询。

html - 如何使用 CSS 将 div 样式化为三 Angular 形?

python - 如果Python中的单元格包含特定字符,如何为其着色?

grails - Grails中的一对一关系显示

grails - grails错误:请求的资源不可用

hibernate - 在 grails 的后台线程中调用 Hibernate

logging - 如何在 gradle 任务中使用 log4j

c++ - qt 样式 QPalette::windowText 颜色在应用程序启动后恢复

java - 我可以在 Grails 中使用 @Async 注释吗

grails - grails:在实例上使用 “count()”代替