你可以将表格行的高度设置为0吗? IE 8,Chrome,Firefox,Opera.
你为什么问!那么,当用户单击父行时,我有一行动态构建和显示.麻烦的是,如果没有行,单击时,它仍然会显示一个空的1像素高排.
这是子网格视图:
<asp:TemplateField HeaderStyle-CssClass="hidden-column" ItemStyle-CssClass="hidden-column" FooterStyle-CssClass="hidden-column"> <ItemTemplate> <tr> <td colspan="8" > <div id='<%# Eval("PublicationID") %>' style="display: none; position: relative;"> <asp:GridView ID="GridView2_ABPubs" runat="server" AutoGenerateColumns="false" Width="100%" DataKeyNames="PublicationID" Font-Names="Verdana" Font-Size="small"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="ChildPublicationSelector" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="NameAbbrev" HeaderText="Publication Name" SortExpression="NameAbbrev" /> </Columns> </asp:GridView> </div> </td> </tr> </ItemTemplate> </asp:TemplateField>
CSS:
.hidden-column { display: none; }
JavaScript的:
<script language="JavaScript" type="text/javascript"> var currentlyOpenedDiv = ""; function CollapseExpand(object) { var div = document.getElementById(object); //if (currentlyOpenedDiv != "" && currentlyOpenedDiv != div) { // currentlyOpenedDiv.style.display = "none"; //} if (div.style.display == "none") { div.style.display = "inline"; currentlyOpenedDiv = div; } else { div.style.display = "none"; } } </script>