This is a migrated thread and some comments may be shown as answers.

How do I add nested grids in radgrid?

1 Answer 1343 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Felice
Top achievements
Rank 1
Felice asked on 01 Oct 2014, 08:09 PM
I can do this in a normal asp grid but I do not know how to achieve the same with radgrid.

In a asp grid I add nested grids like this:

<asp:TemplateField>
    <ItemTemplate>
        <asp:GridView ID="secondLevelGrid"  runat="server" AutoGenerateColumns="false" CssClass="ChildGrid" OnRowDataBound="secondLevelGrid_OnRowDataBound">
                    <Columns>
 
                        <%--My new nested  grid goes here--%>
 
                        <asp:BoundField DataField="Id" HeaderText="Id" />
                        <asp:BoundField DataField="Code" HeaderText="Code" />
                        <asp:BoundField DataField="Quantity" HeaderText="Q.ty" />
                        </Columns>
            </asp:GridView>
    </ItemTemplate>
</asp:TemplateField>

How do I make the above in a radgrid considering that I have 7 level nested grids?

protected void firstLevelGrid_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        GridView firstLevelGrid = e.Row.NamingContainer as GridView;
        string code = firstLevelGrid.DataKeys[e.Row.RowIndex].Value.ToString();
        GridView secondLevelGridView = e.Row.FindControl("secondLevelGrid") as GridView;
        secondLevelGridView.DataSource = //GetData
        secondLevelGridView.DataBind();
    }
}
How do I make the equivalent of the OnRowDataBound for each nested grid in RadGrid?

Thanks for helping. If someone could please show me how to achieve the above in RadGrid then I will add the additional six level nesting I need. Thanks

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 02 Oct 2014, 09:54 AM
Hi Felice,

How you can add nested grid inside the grid NestedViewTemplate is demonstrates in the demo below: 
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/hierarchy-with-templates/defaultcs.aspx

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Felice
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or