Hide Expand/Collapse Buttin in Nested Gridview

15 posts, 0 answers
  1. Akhil Raj
    Akhil Raj avatar
    69 posts
    Member since:
    Aug 2012

    Posted 04 Feb 2010 Link to this post

    hi ,
      I am using rad controld for asp.net ajax and use radgrid for self reference heirarchy. All working nice.
    But now i want to hide the built in collapse / expand button when not have child view in the row. How can i achive this?
  2. Akhil Raj
    Akhil Raj avatar
    69 posts
    Member since:
    Aug 2012

    Posted 05 Feb 2010 Link to this post

    i solved the problem..
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Balu
    Balu avatar
    3 posts
    Member since:
    Aug 2012

    Posted 08 Aug 2012 Link to this post

    hi Akhil Raj

    my requirement also same as of you,can you please share your code ? 
  5. Akhil Raj
    Akhil Raj avatar
    69 posts
    Member since:
    Aug 2012
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Aug 2012 Link to this post

    Hi Bala,

    Try the following code in PreRender event to hide expand collapse button when there are no records in self referencing hierarchy.
    C#:
    protected void RadGrid1_PreRender(object sender, System.EventArgs e)
    {
        RemoveExpandIconWhenNoRecords(RadGrid1.MasterTableView);
    }
    protected void RemoveExpandIconWhenNoRecords(GridTableView view)
    {
        if (view.Controls.Count > 0)
        {
            foreach (GridItem item in view.Controls[0].Controls)
            {
                if (item is GridNestedViewItem)
                {
                    GridNestedViewItem nestedViewItem = (GridNestedViewItem)item;
                    if (nestedViewItem.NestedTableViews[0].Items.Count == 0)
                    {
                        TableCell cell = nestedViewItem.NestedTableViews[0].ParentItem["ExpandColumn"];
                        cell.Controls[0].Visible = false;
                        cell.Text = " ";
                        nestedViewItem.Visible = false;
                    }
                    else
                    {
                        RemoveExpandIconWhenNoRecords(nestedViewItem.NestedTableViews[0]);
                    }
                }
            }
        }
    }

    Thanks,
    Shinu.
  7. Balu
    Balu avatar
    3 posts
    Member since:
    Aug 2012

    Posted 09 Aug 2012 Link to this post

    Thank you for your quick reply,

    My Requirement is i have One Grid say RadGrid1 , inside of RadGrid1 i have taken one more Grid as a GridTableView.

    here my my question is how i will provide paging and Colloapse/Expand functionality for GridTableView (to inner grid).
  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Aug 2012 Link to this post

    Hi,

    You can set AllowPaging and ExpandCollapse column for the DetailTable as shown below.
    aspx:
    <DetailTables>
      <telerik:GridTableView AllowPaging="true" PageSize="4" AutoGenerateColumns="false" ExpandCollapseColumn-Display="true" DataKeyNames="OrderID">
          . . .
      </telerik:GridTableView>
    </DetailTables>

    Thanks,
    Shinu.
  9. Balu
    Balu avatar
    3 posts
    Member since:
    Aug 2012

    Posted 10 Aug 2012 Link to this post

    thanks all for quick response

    http://www.dotnetspeaks.com/LiveDemos/ASP.NET/GridView/NestedGridViewPaging.aspx 

    please check above link.i want same functionality using Netsed Rad Grid Views (both paging and expand and collapse functionality)  



  10. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Aug 2012 Link to this post

    Hi,

    Try the following code to show paging in inner grid. Also take a look into this demo.
    aspx:
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource1">
       <MasterTableView DataKeyNames="CustomerID" CommandItemDisplay="Top">
        <NestedViewSettings DataSourceID="SqlDataSource2">
          <ParentTableRelation>
              <telerik:GridRelationFields MasterKeyField="CustomerID" DetailKeyField="CustomerID" />
         </ParentTableRelation>
       </NestedViewSettings>
       <Columns>
        . . .
       </Columns>
       <NestedViewTemplate>
        <telerik:RadGrid AllowPaging="true" PageSize="2" ID="RadGrid2" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource2">
         <MasterTableView DataKeyNames="OrderID">
           <Columns>
            . . .
           </Columns>
         </MasterTableView>
        </telerik:RadGrid>
       </NestedViewTemplate>
      </MasterTableView>
    </telerik:RadGrid>

    Thanks,
    Shinu.
  11. Khaja
    Khaja avatar
    2 posts
    Member since:
    Aug 2012

    Posted 31 Aug 2012 Link to this post

    i have a nested grid view with in a gridview,my problem is when i am firing textchanged event in nested gridview nested grid view is collapsing with master gridview,how to show nested gridview after the event is fired.

    Thanks in advance
    Naseer
  12. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 04 Sep 2012 Link to this post

    Hi Khaja,

    I have created a sample RadGrid web site to test the described approach. On my side everything works as expected and the grid's expanded state is correctly preserved. Please check out the attached application and try to distinguish the crucial differences between our projects.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  13. Khaja
    Khaja avatar
    2 posts
    Member since:
    Aug 2012

    Posted 04 Sep 2012 Link to this post

    thank you for your reply

    I placed my code on update panel so its getting merging,if i removing update panel every time refresh is happening,how to solve it
    <div class="rnd1">
                        <asp:UpdatePanel ChildrenAsTriggers="true" UpdateMode="Conditional" ID="UpdatePanel2"
                            runat="server">
                            <ContentTemplate>
                        <asp:GridView ID="grdQuotMaster" AllowPaging="True" ExpandCollapseColumn-Display="true"
                            BackColor="#f1f1f1" Width="100%" CssClass="GridViewStyle" AutoGenerateColumns="false"
                            DataKeyNames="QuotId" Style="z-index: 101; left: 8px;" Font-Size="Small" Font-Names="Verdana"
                            runat="server" GridLines="None" OnRowCommand="grdQuotMaster_RowCommand" OnRowDataBound="grdQuotMaster_RowDataBound"
                            AllowSorting="true" OnSelectedIndexChanging="grdQuotMaster_SelectedIndexChanging"
                            OnPageIndexChanging="grdQuotMaster_PageIndexChanging">
                            <RowStyle BackColor="#E3EAEB" />
                            <AlternatingRowStyle BackColor="White" />
                            <PagerStyle CssClass="PagerStyle" />
                            <SelectedRowStyle BackColor="#A2DDDA" />
                            <HeaderStyle ForeColor="White" Font-Bold="true" CssClass="HeaderStyle" />
                            <FooterStyle BackColor="White" />
                            <Columns>
                                <asp:CommandField ButtonType="Image" SelectImageUrl="~/images/GSel.gif" ShowCancelButton="False"
                                    ShowSelectButton="True" SelectText="Edit" ItemStyle-Width="15px">
                                    <ItemStyle Width="15px"></ItemStyle>
                                </asp:CommandField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <a href="javascript:expandcollapse('div<%# Eval("QuotId") %>', 'one');">
                                            <img id="imgdiv<%# Eval("QuotId") %>" alt="Click to show/hide Orders for Customer <%# Eval("QuotId") %>"
                                                width="9px" border="0" src="images/plus.gif" />
                                        </a>
                                    </ItemTemplate>
                                </asp:TemplateField>
                      
                                <asp:BoundField HeaderText="Quotation.No" DataField="QuotId"></asp:BoundField>
                                <asp:BoundField HeaderText="Enquiry.No" DataField="enqId"></asp:BoundField>
                                <asp:TemplateField HeaderText="Customer ID" Visible="false">
                                    <ItemTemplate>
                                        <asp:Label ID="lblCustId" Text='<%# Eval("custId") %>' runat="server"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                
                                <asp:BoundField HeaderText="CustomerName" DataField="custname"></asp:BoundField>
                                <asp:BoundField HeaderText="Quotation Date" DataField="QuotDate" DataFormatString="{0:dd/MM/yyyy}">
                                </asp:BoundField>
                                <asp:BoundField HeaderText="Amount" DataField="Amount"></asp:BoundField>
                                <asp:BoundField HeaderText="Status" DataField="Status"></asp:BoundField>
                                <asp:ButtonField ButtonType="button" CommandName="Stop" Text="Stop" />
                                <asp:ButtonField ButtonType="button" CommandName="Print" Text="Print" />
                                <asp:ButtonField ButtonType="button" CommandName="Email" Text="Email" />
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <tr>
                                            <td colspan="100%">
                                                <asp:UpdatePanel ChildrenAsTriggers="true" ID="UpdatePanel2" UpdateMode="Conditional" runat="server">
                                                    <ContentTemplate>
                                                <div id="div<%# Eval("QuotId") %>" style="display: none; position: relative; left: 15px;
                                                    overflow: auto; width: 97%" class="rnd1">
                                                    <asp:GridView ID="grdQuotDetails" AllowPaging="True" AllowSorting="true" BackColor="White"
                                                        Width="100%" CssClass="GridViewStyle " AutoGenerateColumns="false" Font-Names="Verdana"
                                                        ExpandCollapseColumn-Display="true" runat="server" DataKeyNames="QuotId" ShowFooter="true"
                                                        OnPageIndexChanging="grdQuotDetails_PageIndexChanging" OnRowUpdating="grdQuotDetails_RowUpdating"
                                                        OnRowCommand="grdQuotDetails_RowCommand" OnRowEditing="grdQuotDetails_RowEditing"
                                                        GridLines="None" OnRowUpdated="grdQuotDetails_RowUpdated" OnRowCancelingEdit="grdQuotDetails_CancelingEdit"
                                                        OnRowDataBound="grdQuotDetails_RowDataBound" OnRowDeleting="grdQuotDetails_RowDeleting"
                                                        OnRowDeleted="grdQuotDetails_RowDeleted" OnSorting="grdQuotDetails_Sorting">
                                                        <RowStyle BackColor="#E3EAEB" />
                                                        <AlternatingRowStyle BackColor="White" />
                                                        <HeaderStyle ForeColor="White" CssClass="HeaderStyle" />
                                                        <FooterStyle BackColor="White" />
                                                        <Columns>
                                                            <asp:TemplateField HeaderText="QuotDetID">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblQuotDetID" Text='<%# Eval("QuotDetID") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:Label ID="lblQuotDetID" Text='<%# Eval("QuotDetID") %>' runat="server"></asp:Label>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="ProdId">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblProdId" Text='<%# Eval("ProdId") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:Label ID="lblProdId" Text='<%# Eval("ProdId") %>' runat="server"></asp:Label>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="UOM">
                                                                <ItemTemplate>
                                                                    <%# Eval("Packetsize")%></ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtPacketsize" Text='<%# Eval("Packetsize")%>' runat="server" Width="50%"></asp:TextBox>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Qty">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblQuantity" Text='<%# Eval("Quantity")%>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtQuantity" Text='<%# Eval("Quantity")%>' runat="server" AutoPostBack="true"
                                                                        OnTextChanged="txtQuantity_TextChanged" Width="50%" onkeypress="update"></asp:TextBox>
                                                                    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="true" >
                                                                        <ContentTemplate>
                                                                        <asp:TextBox ID="txtQuantity" Text='<%# Eval("Quantity")%>' runat="server" AutoPostBack="true"
                                                                        OnTextChanged="txtQuantity_TextChanged" Width="50%" onkeypress="update"></asp:TextBox>
                                                                        </ContentTemplate>
                                                                        <Triggers>
                                                                            <asp:AsyncPostBackTrigger ControlID="txtQuantity" EventName="TextChanged" />
                                                                        </Triggers>
                                                                        </asp:UpdatePanel>--%>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Price">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblSalesprice" Text='<%# Eval("salesPrice")%>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtsalesPrice" Text='<%# Eval("salesPrice")%>' runat="server" AutoPostBack="true"
                                                                        OnTextChanged="txtsalesPrice_TextChanged" Width="75%"></asp:TextBox>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="Amount">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblAmount" Text='<%# Eval("Amount") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtAmount" Text='<%# Eval("Amount") %>' runat="server" Width="75%"></asp:TextBox>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="InstallationRate">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblInstallationRate" Text='<%# Eval("InstallationRate") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtInstallationRate" Text='<%# Eval("InstallationRate") %>' runat="server"
                                                                        Width="50%" AutoPostBack="true" OnTextChanged="txtInstallationRate_TextChanged"></asp:TextBox>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="InstallationAmount">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblIstallationAmt" Text='<%# Eval("InstallationAmount") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtIstallationAmt" Text='<%# Eval("InstallationAmount") %>' runat="server"
                                                                        Width="50%"></asp:TextBox>
                                                                </EditItemTemplate>
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="InstallationTaxAmount">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblIstallationTaxAmt" Text='<%# Eval("IstallationTaxAmt") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtIstallationTaxAmt" Text='<%# Eval("IstallationTaxAmt") %>' runat="server"
                                                                        Width="50%"></asp:TextBox>
                                                                </EditItemTemplate>
                                                                
                                                            </asp:TemplateField>
                                                            <asp:TemplateField HeaderText="ProductTaxAmount">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblproducttaxamt" Text='<%# Eval("ProductTaxAmt") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:TextBox ID="txtproducttaxamt" Text='<%# Eval("ProductTaxAmt") %>' runat="server"
                                                                        Width="75%"></asp:TextBox>
                                                                </EditItemTemplate>
                                                            
                                                     <FooterTemplate>
                                                       <asp:LinkButton ID="linkAddOrder" CommandName="AddOrder" runat="server">Add</asp:LinkButton>
                                                        <asp:ImageButton ID="imgbtnAdd" runat="server" CausesValidation ="true"  ImageUrl="~/Images/insert.jpg" CommandName="AddOrder"  ToolTip="Add" Height="20px" Width="20px"  />
                                                     
                                                     </FooterTemplate>--%>
                                                                <ItemTemplate>
                                                                    <asp:ImageButton ID="imgbtnEdit" CommandName="Edit" runat="server" ImageUrl="~/Images/edit.jpg"
                                                                        ToolTip="Edit" Height="20px" Width="20px" />
                                                      
                                                                </ItemTemplate>
                                                                <EditItemTemplate>
                                                                    <asp:ImageButton ID="imgbtnUpdate" CommandName="Update" runat="server" CausesValidation="true"
                                                                        ImageUrl="~/Images/update.jpg" ToolTip="Update" Height="20px" Width="20px" />
                                                                    <asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ImageUrl="~/images/cancel2.png"
                                                                        ToolTip="Cancel" Height="20px" Width="20px" />
                                                                </EditItemTemplate>
                                                                <ItemStyle Width="60px" />
                                                             
                                                            </asp:TemplateField>
                                                        </Columns>
                                                    </asp:GridView>
                                                </div>
                                                </ContentTemplate> </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                      
                        </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
    thanks in advance,
    Naseer
  14. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 06 Sep 2012 Link to this post

    Hello Khaja,  

    Please note that when you have declared AutoPostBack=true to your controls, their events will cause a regular postbacks to the server.

    It is difficult to figure out your exact requirements by the provided information so far. Could you please elaborate some more on what you want to achieve?

    Kind regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  15. Khyati
    Khyati avatar
    1 posts
    Member since:
    Mar 2013

    Posted 20 Mar 2013 Link to this post

    hello,

    I use nested grid and checkbox in radgrid  in my website.. and i m trying to expand nested grid on checkbox checkedchanged event..
    but on checkedchange event i can't find control of panel which is in nested grid.. 
    Anybody can please help me.... 
  16. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Mar 2013 Link to this post

    HI,

    Try the following code to access Panel in NestedViewTemplate.
    C#:
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
           foreach (GridNestedViewItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))
            {
                Panel pnl = (Panel)item.FindControl("Panel1");
            }
    }

    Thanks,
    Princy
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017