0
我有以下幾個將枚舉模型並添加發票和日期。 然後,我希望有一張表,其中包含每張發票可摺疊的發票行項目。我不知道如何在枚舉模型時如何做到這一點,我不知道如何唯一地標識表,然後我不知道如何告訴jquery函數我們需要隱藏哪個表。帶有枚舉列表的JQuery隱藏表
這裏是我現在的代碼。我在我想要隱藏的表旁邊添加了一條評論。上面有一個錨標籤,它調用jQuery隱藏功能的javascript函數是
<table class="themedtable"
cellspacing="0">
<tr>
<th style="text-align: left">
Invoice
</th>
<th>
Order Date
</th>
</tr>
<% foreach (var item in Model)
{ %>
<tr>
<td style="text-align: left">
<strong>
<%=Html.Encode(item.Invoice)%></strong>
</td>
<td>
<%=Html.Encode(String.Format("{0:d}",item.invcte))%>
</td>
</tr>
<tr>
<td colspan="2">
<a href="javascript:toggletable()">Show/Hide Table</a>
</td>
</tr>
<%if (item.LineItemList.Count > 0)
{ %>
<tr>
<td>
<table style="margin-left: auto; margin-right: auto; width: 90%" cellspacing="0"> //this is the table i need to id and collapse when the above link is clicked
<tr>
<th>
Part
</th>
<th>
Desc
</th>
<th>
Qty
</th>
<th>
Qty Shipped
</th>
<th>
Status
</th>
</tr>
<%foreach (var lineItem in item.LineItemList)
{ %>
<tr>
<td style="width: 10%">
<%=Html.Encode(lineItem.Partno) %>
</td>
<td style="width: 50%">
<%=Html.Encode(lineItem.Description) %>
</td>
<td style="width: 10%">
<%=Html.Encode(lineItem.Qty) %>
</td>
<td style="width: 20%">
<%=Html.Encode(lineItem.QtyShipped) %>
</td>
<td style="width: 10%">
<%=Html.Encode(lineItem.Status) %>
</td>
</tr>
<%} %>
</table>
</td>
</tr>
<%} %>
<%} %>
</table>
<script type="text/javascript">
function toggletable() {
$(//selector).hide();
}
我喜歡這個想法,我會與之合作。謝謝!您是否認爲有一種方法可以識別div並將其提供給ajax方法,以便它直接顯示在點擊的發票號碼下方,但位於下一個發票號碼的上方? – twal 2010-09-16 14:22:44
是的。但你不需要。您可以使用jQuery將新的HTML直接放置在點擊元素之後,從而否定自己找到元素並放置新元素的需要。 jQuery負責所有這些 – griegs 2010-09-16 22:24:37