js-某个字段有值即把该行用颜色标记

本文介绍了一种在显示表格中突出显示特定分类数据的方法。通过后台SQL查询将所需分类排在前列,并使用前台标签根据分类字段值改变行背景色。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题场景

需求:classfication字段98%为空,其余的为adsss,当值为adsss时把该行用红色标记下并排在前面。

解决方法

后台SQL查询的时候语句末尾加上order by classfication desc 实现排在前面;
前台用一个if标签设置tr的style。

效果

这里写图片描述

CODE

<c:choose>
                <c:when test="${not empty readyTestResultList}">
                    <c:forEach items="${readyTestResultList}" var="readyTestResult" varStatus="vs">
                    <tr class="main_info" id="tr${readyTestResult.id}"
                        <c:if test="${readyTestResult.classification!=null and readyTestResult.classification != ''}">
                            style="background:red;word-wrap:break-word;"
                        </c:if>
                        <c:if test="${readyTestResult.classification==null or readyTestResult.classification == ''}">
                            style="word-wrap:break-word;"
                        </c:if>
                    >
                        <td><input type="checkbox" onclick="setBgColor(this.parentNode.parentNode);" name="id" id="readyTestResultIds${readyTestResult.id}" value="${readyTestResult.id}"/></td>
                        <td>${vs.index+1}</td> 
                        <td>${readyTestResult.annoId1}</td>
                        <td>${readyTestResult.batchNum}</td>
                        <td>${readyTestResult.sampleNum}</td>
                        <td>${readyTestResult.gene}</td> 
                        <td>${readyTestResult.HGVS}</td>
                        <td>${readyTestResult.freqOrAvgNum}</td>
                        <td> 
                            <a href="javascript:show(${readyTestResult.id});">查看</a> |
                            <a href="javascript:edit(${readyTestResult.id});">修改</a> | 
                            <a href="javascript:deleteReadyTestResult(${readyTestResult.id});">删除</a>
                            <c:if test="${showIdRecycle==0}">
                                <a href="javascript:restoreReadyTestResult(${readyTestResult.id});">| 还原</a>
                            </c:if>
                        </td> 
                    </tr>
                    </c:forEach>
                </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="32">没有相关数据</td>
                </tr>
            </c:otherwise>
        </c:choose>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值