隐藏并显示表格列

时间:2013-03-13 21:08:54

标签: jquery jsp spring-mvc controller

我需要根据从spring控制器传递的模型Object隐藏最后一列复选框。如果模型值是“isAll”列应该隐藏,如果任何其他值它应该是可见的我已经尝试但到目前为止失败。我不确定我是否正确传递了控制器的值。帮助!

控制器:

    System.err.println("Type is: " + formbean.getType());
System.err.println("IscCode is: " + formbean.getForecastIsc());
System.err.println("ActualIscCode is: " + formbean.getActualIsc());
System.err.println("labelNbr is: " + formbean.getLabelNbr());
System.err.println("senderOp is: " + formbean.getSenderOp());       
System.err.println("senderLastName is: " + formbean.getSenderLastName());
System.err.println("receiverOp is: " + formbean.getReceiverOp());
System.err.println("receiverLastName is: " + formbean.getReceiverLastName());


    summary = summarySelectDao.getSummary(formbean);    
    if(summary == null || summary.size() == 0){         
        errorMessage = "No Parcel Analysis Cases Found!";
return new ModelAndView("redirect:/analysis/analysisSelection? hasError=true");
    }else{
    logger.info("Total " + summary.size() + " analysis cases found from DB.");
        model.addObject("summary", summary);
        model.addObject("isAll", true);  //BASED on this model if true
    }

    return model;       

JSP:

<td class="ct"<c:out value="${summary.country}" /></td>
 <td class="sc" <c:out value="${summary.source}" /></td>
 <td  class="cb" <input type="checkbox" value=""> </td>

JS:

$(document).ready(function() {
$(".cb").hide();    
}); 

HTML:

   <div id=table1>
<table id="summaryTable" class="sortable">
    <thead>
        <tr>
            <th>&nbsp;</th>
            <th>Bar Code</th>
            <th>Origin</th>
            <th>Sender Name</th>
            <th>Recipient Name</th>
            <th>USPS Mail<br>Receipt Date</th>
            <th><br>Load Date</th>
            <th>Fore-<br>cast<br> ISC</th>
            <th>Act-<br>ual<br> ISC</th>
            <th>Country</th>
            <th>Source</th>
<th class="cb"><input type="button" id="btnSelectAllCbl" name="selectCheckBox"
            value="Update"> </th>
        </tr>
    </thead>
    <tbody> 
        <tr>

                <tr>
<td bgcolor='yellow'>P
    </td>
    <td bgcolor='yellow'><a href="AnalysisController?value=xxxxx">xxxxx
    </a>
    </td>
    <td bgcolor='yellow'>55025
                    </td>
    <td bgcolor='yellow'>xxxx
                    </td>
    <td bgcolor='yellow'>SON
    </td>
 <td  bgcolor='yellow'>
        </td>
<td bgcolor='yellow'>2013/02/11 060205
</td>
<td bgcolor='yellow'>ORD
                    </td>
<td bgcolor='yellow'>ORD
                    </td>
                    <td  bgcolor='yellow'>SINGAPORE
                    </td>
                    <td  bgcolor='yellow'>RECIPIENT
                    </td>
                    <td class="cb" bgcolor='yellow'><input
                        type="checkbox" value="">
                    </td>

1 个答案:

答案 0 :(得分:1)

最简单的方法:使用<c:if>来打印/不打印列:

<c:if test="${isAll}">
    <td  class="cb"><input type="checkbox" value=""></td>
</c:if>

同样对列标题也这样做。

相关问题