Click here to Skip to main content
14,934,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have four nested grid view When I click + image the next grid view will open but the problem is the inner grid appears after leaving a columns like this now i want that inner grid should also appear same without leaving columns in left and right side

- A 0 0 0 0
+ B 0 0 0 0

Is there any way to do this

XML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("[id*=imgLevel1]").each(function () {
                if ($(this)[0].src.indexOf("minus") != -1) {
                    $(this).closest("tr").after("<tr><td colspan = '10'>" + $(this).next().html() + "</td></tr>");
                    $(this).next().remove();
                }
            });
            $("[id*=imgLevel2]").each(function () {
                if ($(this)[0].src.indexOf("minus") != -1) {
                    $(this).closest("tr").after("<tr><><td colspan = '10'>" + $(this).next().html() + "</td></tr>");
                    $(this).next().remove();
                }
            });
            $("[id*=imgLevel3]").each(function () {
                if ($(this)[0].src.indexOf("minus") != -1) {
                    $(this).closest("tr").after("<tr><td colspan = '10'>" + $(this).next().html() + "</td></tr>");
                    $(this).next().remove();
                }
            });
        });
    </script>



XML
<asp:Panel runat="server" ID="pnlLevel1" BorderColor="Gray" BorderWidth="1px" Width="100%" >
 <table style="width:100%; height:100%;">
 <tr>
 <td>
  <asp:GridView ID="gvLevel1" runat="server" AutoGenerateColumns="false"
           PageSize="40" Width="100%" Height="100%"
        DataKeyNames="LocID" onrowdatabound="gvLevel1_RowDataBound">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:ImageButton ID="imgLevel1" runat="server" OnClick="Show_Hide_Level1Grid"
                        ImageUrl="~/images/plus.png" CommandArgument="Show" />
                      <asp:Panel ID="pnlLevel2" runat="server"  Style="position: relative;margin-left:-5px; border-color:Red; border-width:1px;" Width="100%">
                        <asp:GridView ID="gvLevel2" runat="server" AutoGenerateColumns="false" Width="100%" ShowHeader="false"
                         DataKeyNames="LocID" PageSize="40" OnRowDataBound="gvLevel2_RowDataBound"
                          Style="position: relative;margin-left:-5px;">
                            <Columns>
                                <asp:TemplateField ItemStyle-Width="40px">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="imgLevel2" runat="server" OnClick="Show_Hide_Level2Grid"
                                            ImageUrl="~/images/plus.png" CommandArgument="Show" />
                                        <asp:Panel ID="pnlLevel3" runat="server" Style="position: relative;margin-left:-7px;" Width="100%">
                                            <asp:GridView ID="gvLevel3" runat="server" AutoGenerateColumns="false" Width="100%"
                                                  onrowdatabound="gvLevel3_RowDataBound" ShowHeader="false" Style="position: relative;margin-left:-6px;"
                                               DataKeyNames="LocID" PageSize="40">
                                               <Columns>
                                                <asp:TemplateField ItemStyle-Width="40px">
                                                <ItemTemplate>
                                                  <asp:ImageButton ID="imgLevel3" runat="server" OnClick="Show_Hide_Level3Grid"
                                                    ImageUrl="~/images/plus.png" CommandArgument="Show" />
                                                     <asp:Panel ID="pnlLevel4" runat="server" Style="position: relative;margin-left:-7px;" Width="100%">
                                                    <asp:GridView ID="gvLevel4" runat="server" AutoGenerateColumns="false"
                                                    PageSize="40" Width="100%" ShowHeader="false" Style="position: relative;margin-left:-6px;"
                                                    onrowdatabound="gvLevel4_RowDataBound" DataKeyNames="LocID">

                                                    <Columns>
                                                     <asp:BoundField ItemStyle-Width="390px" ItemStyle-HorizontalAlign="Center" DataField="SubName" ItemStyle-Font-Bold="true"/>
                                                      <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" DataField="DraftCount" ItemStyle-Height="40px"  />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="SubmittedCount" />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="ApproveCount" />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="RejectCount" />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="EditCount" />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="LockCount" />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="PendingCount" />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="ReportCount"  />
                                                    </Columns>
                                                   </asp:GridView>
                                                  </asp:Panel>
                                                </ItemTemplate>
                                                </asp:TemplateField>
                                                    <asp:BoundField ItemStyle-Width="323px" ItemStyle-HorizontalAlign="Center" DataField="SubName" ItemStyle-Font-Bold="true"/>
                                                     <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" DataField="DraftCount" ItemStyle-Height="40px"  />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="SubmittedCount"  />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="ApproveCount"  />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="RejectCount" />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="EditCount"  />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="LockCount"  />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="PendingCount"  />
                                                    <asp:BoundField ItemStyle-Width="40px" ItemStyle-Height="40px" ItemStyle-HorizontalAlign="Center" DataField="ReportCount"  />
                                                </Columns>
                                            </asp:GridView>
                                        </asp:Panel>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                 <asp:BoundField ItemStyle-Width="313px" ItemStyle-HorizontalAlign="Center" DataField="SubName" ItemStyle-Font-Bold="true"/>
                                   <asp:BoundField ItemStyle-Width="42px" DataField="DraftCount" ItemStyle-HorizontalAlign="Center"  ItemStyle-Height="40px" />
                                   <asp:BoundField ItemStyle-Width="40px" DataField="SubmittedCount" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px"  />
                                   <asp:BoundField ItemStyle-Width="40px" DataField="ApproveCount" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" />
                                   <asp:BoundField ItemStyle-Width="40px" DataField="RejectCount" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" />
                                   <asp:BoundField ItemStyle-Width="40px" DataField="EditCount" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px"  />
                                   <asp:BoundField ItemStyle-Width="40px" DataField="LockCount" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" />
                                   <asp:BoundField ItemStyle-Width="40px" DataField="PendingCount" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" />
                                   <asp:BoundField ItemStyle-Width="40px" DataField="ReportCount" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px"  />
                            </Columns>
                        </asp:GridView>
                    </asp:Panel>

              </ItemTemplate>
          </asp:TemplateField>
            <asp:BoundField ItemStyle-Width="300px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="SubName" HeaderText="Location Name" ItemStyle-Font-Bold="true"/>
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="DraftCount" HeaderImageUrl="~/images/actions/draft.png" />
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="SubmittedCount" HeaderImageUrl="~/images/actions/submit_report_hover.png" />
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="ApproveCount" HeaderImageUrl="~/images/actions/approve_hover.png" />
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="RejectCount" HeaderImageUrl="~/images/actions/reject_hover.png" />
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="EditCount" HeaderImageUrl="~/images/actions/edit_icon.png" />
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="LockCount" HeaderImageUrl="~/images/actions/lock.png" />
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="PendingCount" HeaderImageUrl="~/images/actions/pending_icon_hover.png" />
            <asp:BoundField ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="40px" DataField="ReportCount"  />
       </Columns>
    </asp:GridView>
  </td>
 </tr>
</table>
 </asp:Panel>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900