2013-03-13 182 views
0

我需要隱藏最後一列,這是複選框基於從彈簧控制器傳遞的模型對象。如果模型值是「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> 
+0

你根本沒有顯示HTML,或只是沒有隱藏最後一列?如果您嘗試在單元格中顯示值,我認爲JSP中的HTML無效。您需要在 2013-03-13 21:12:35

+1

它應該在​​正確關閉時工作,請點擊此處查看:http://jsfiddle.net/D2LR3/ – gnysek 2013-03-13 21:15:39

+0

對不起,可能會讓我困惑一下。隱藏功能工作正常,但我需要的是,它只隱藏列時,從控制器傳遞的值是「isAll」,否則它應該顯示該列,現在它隱藏列,即使「isAll」爲假 – Fahad 2013-03-13 21:33:24

回答

1

最簡單的方法:用<c:if>爲了打印/不打印列在所有:

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

執行相同的列標題爲好。

+0

謝謝!@Luiggi Mendoza所以通過使用我仍然需要使用jquery?如果是,你可以詳細說明我將如何編碼該部分.. – Fahad 2013-03-14 14:36:54

+0

不,請刪除jquery部分。 – 2013-03-14 14:37:15

+0

K.謝謝我會嘗試! – Fahad 2013-03-14 14:41:45