展开所有javascript函数

时间:2017-02-28 06:47:20

标签: javascript asp.net

您好我是JS和HTML的新手。我正在编写下面的代码。我试图在转发器中创建一个网格。我从网格获取3列数据,从数据网格获取2列数据。我已经创建了用于单独扩展行的javascript函数,我添加了我尝试过的代码。请任何人建议我如何在按钮点击上展开所有行(展开全部)。



function divexpandcollapse(divname) {
  var div = document.getElementById(divname);
  var img = document.getElementById('img' + divname);
  if (div.style.display == "none") {
    div.style.display = "inline";
    img.src = "Minus.gif";
  } else {
    div.style.display = "none";
    img.src = "Plus.gif";
  }
}

<tr>
  <td>
    <div id="div" style="DISPLAY: block; OVERFLOW: auto; POSITION: static; HEIGHT: 150px;">
      <table cellspacing="0" cellpadding="0" border="0" width="100%">
        <tr>
          <td>
            <asp:Repeater ID="rptMain" runat="server">
              <HeaderTemplate>
                <tr>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td></td><!-- I have multiple header columns in here like document, details ,date, changedate,type etc -->
                </tr>
              </HeaderTemplate>
              <ItemTemplate>
                <tr>
                  <td>
                    <a href="JavaScript:divexpandcollapse('div<%# Eval(" attachment_seq ")%>');">
                        <img id="imgdiv<%# Eval("attachment_seq") %>" border="1" src="Plus.gif" alt="" /></a>
                  </td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td></td><!--  first 3 columns are document,details,date -->
                </tr>
                <tr id='trrow' runat="server">
                  <td colspan="5">
                    <div id="div<%# Eval('attachment_seq')%>" style="overflow: auto; display:none; height:auto;">
                      <asp:DataGrid id="tempgrd" Runat="server" cellspacing="0" cellpadding="0" border="0">
                        <Columns>
                          <asp:BoundColumn ItemStyle-Width="1%" ItemStyle-VerticalAlign="Top"></asp:BoundColumn>
                          <asp:BoundColumn ItemStyle-Width="1%" ItemStyle-VerticalAlign="Top"></asp:BoundColumn>
                          <asp:BoundColumn ItemStyle-Width="1%" ItemStyle-VerticalAlign="Top"></asp:BoundColumn>
                          <asp:BoundColumn ItemStyle-Width="1%" ItemStyle-VerticalAlign="Top"></asp:BoundColumn>
                          <asp:BoundColumn ItemStyle-Width="1%" ItemStyle-VerticalAlign="Top"></asp:BoundColumn> <!-- last 2 columns are changedate and type -->
                        </Columns>
                      </asp:DataGrid>
                    </div>
                  </td>
                </tr>
              </ItemTemplate>
            </asp:Repeater>
          </td>
        </tr>
      </table>
    </div>
  </td>
</tr>
&#13;
&#13;
&#13;

0 个答案:

没有答案