如果在gsp中包含特定值,是否可以更改表格行颜色? [英] Is it possible to change table row colour if it contains a certain value in a gsp?

查看:99
本文介绍了如果在gsp中包含特定值,是否可以更改表格行颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 < table class =table table-striped > 
< tr>
< td>
$ {person.name}
< / td>
< / tr>
< tr>
< td>
$ {person.address}
< / td>
< / tr> ............

我需要突出显示(如果它们出现在gsp中可用的数组中,则更改背景或文本的clour。)



这是可能的吗?例如使用g:if?Like:

 < tr> 
< th scope =row>名称:< / th>
< td>
< g:if $ {array} .contains($ {person.name})>
//改变样式
$ {person.name}
< / g:if>
< / td>
< / tr>


解决方案

这应该可行,但我没有尝试过:

 < td class =$ {array.contains(person.name)?'highlight':''}> 
<因此,如果它包含名称,那么'高亮'类将被添加到 td 中, code>


I have a table in a gsp containing 10 deiiferent values :

<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>............

I need to highlight (either change the background or text clour on some of the values if they are present in an array also available in the gsp.

Is this possible? For example using g:if? Like :

  <tr>
    <th scope="row">Name:</th>
    <td>
               <g:if ${array}.contains("${person.name}")>
        //change styling of this cell
                   ${person.name}
                </g:if>
    </td>
</tr>

解决方案

This should work, but I've not tried it:

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

So if it contains the name, then a 'highlight' class will be added to the td

这篇关于如果在gsp中包含特定值,是否可以更改表格行颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆