博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Javascript 控制tr是否显示

Posted on 2008-09-25 11:01  LonelyStar  阅读(708)  评论(0)    收藏  举报
<asp:GridView ID="GridViewRestricted" CssClass="bigTabList" Width="750px" runat="server"
                    AutoGenerateColumns
="false" OnRowDataBound="GridViewRestricted_RowDataBound">
                    
<Columns>
                    
<asp:TemplateField HeaderText = "Restricted Documents">
                        
<ItemTemplate>
                            
<table border="0" cellpadding="0" cellspacing="0">
                                
<tr>
                                    
<td style='font-size:13px; width:20px;'>
                                        
<asp:CheckBox ID="CheckBoxFolder" runat="server" /> 
                                    
</td>
                                   
<td style="cursor:pointer;width:60px; text-align:left;" onclick="DisplayFiles(this);">Collapse</td> 
<td onclick="parentNode.nextSibling.style.display='none';">Collapse</td>
                                   
<td >
                                       
<asp:Literal ID="LiteralFolder" runat="server"></asp:Literal>
                                   
</td>                                    
                                
</tr>
                                
<tr style="display:block;">
                                    
<td colspan="3">
                                        
<asp:Literal ID="LiteralContent" runat="server"></asp:Literal>
                                    
</td>
                                
</tr>
                                
                            
</table>
                        
</ItemTemplate>
                    
</asp:TemplateField>
                    
</Columns>
                
</asp:GridView>

 

 

<script language="javascript">
   
   
function DisplayFiles(td)
   {
        
if (td.parentNode.nextSibling.style.display != "none")
       { 
            td.parentNode.nextSibling.style.display
='none';
            td.innerHTML 
= "Expand"
       } 
       
else
       {
            td.parentNode.nextSibling.style.display
='block';
           td.innerHTML 
= "Collapse";  
       }
       
   }
   
   
</script>