Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Grid / Autogenerate Hierarchy

Example Configuration
Working with RadGrid's autogenerated hierarchy:
Switch hierarchy load mode:
Set hierarchy expanded by default:


 Customer IDCountryCityCompany NameContact NameTotal OrdersTotal Amount
SEVESUKLondonSeven Seas ImportsHari Kumar2617170.1501083374
OLDWOUSAAnchorageOld World DelicatessenRene Phillips2416323.5498657227
FRANSItalyTorinoFranchi S.p.A.Paolo Accorti101545.69999885559
MAGAAItalyBergamoMagazzini Alimentari RiunitiGiovanni Rovelli217602.79999160767
SIMOBDenmarkKobenhavnSimons bistroJytte Petersen1518136.3499946594
LAZYKUSAWalla WallaLazy K Kountry StoreJohn Steel2357
CHOPSSwitzerlandBernChop-suey ChineseYang Wang2212884.999961853
ERNSHAustriaGrazErnst HandelRoland Mendel102113229.730472565
FRANKGermanyMünchenFrankenversandPeter Franken4828719.5600280762
HILAAVenezuelaSan CristóbalHILARION-AbastosCarlos Hernández4523610.0800743103
CENTCMexicoMéxico D.F.Centro comercial MoctezumaFrancisco Chang2100.799999237061
GOURLBrazilCampinasGourmet LanchonetesAndré Fonseca198700.92997741699
BLONPFranceStrasbourgBlondel père et filsFrédérique Citeaux2619087.2500305176
THEBIUSAPortlandThe Big CheeseLiz Nixon73361

  • This example demonstrates RadGrid's capability to auto-generate a hierarchical representation of a mutli-table DataSet. Just set the AutogenerateHierarchy property of RadGrid to true and it will automatically generate the hierarchy based on the tables in the DataSet and their relations with one another.

    The detail tables generation will start from the table which name has been set to the DataMember property of the DataSet. In other words, RadGrid will assume this data-table as the data source for its MasterTableView. If no table name has been specified for the DataMember of the DataSet object, the first table in the latter will be treated as the data source for the grid's MasterTableView and the generation of the detail tables will go from there following the root data-table child relations.

    The detail tables in the grid will inherit the value for the HierarchyLoadMode property of the MasterTableView as well as the value for the HierarchyDefaultExpanded property.

    Important:
    Autogenerate hierarchy with paging is not supported scenario by our RadGrid control!

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" CodeFile="defaultcs.aspx.cs" Inherits="Telerik.GridExamplesCSharp.Hierarchy.DeclarativeRelations.DefaultCS" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
        <!-- custom head section -->
        <!-- end of custom head section -->
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <telerik:Header runat="server" ID="Header1" NavigationLanguage="CS"></telerik:Header>
       <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:ConfiguratorPanel ID="ConfiguratorPanel1" runat="server" Expanded="true">
                <div class="title" style="font-size: 16px">
                    Working with RadGrid's autogenerated hierarchy:</div>
                <table>
                    <tr>
                        <td style="width: 300px">
                            <span style="font-size: 14px">Switch hierarchy load mode:</span>
    <asp:RadioButtonList AutoPostBack="true" ID="RadioButtonList1" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
    runat="server">

                                <asp:ListItem Text="ServerOnDemand">
                                </asp:ListItem>
                                <asp:ListItem Text="ServerBind">
                                </asp:ListItem>
                                <asp:ListItem Text="Client">
                                </asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                        <td style="width: 300px">
                            <span style="font-size: 14px">Set hierarchy expanded by default:</span>
    <asp:RadioButtonList AutoPostBack="true" ID="RadioButtonList2" OnSelectedIndexChanged="RadioButtonList2_SelectedIndexChanged"
    runat="server">

                                <asp:ListItem Text="True">
                                </asp:ListItem>
                                <asp:ListItem Text="False">
                                </asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                    </tr>
                </table>
                <br />
                <br />
            </telerik:ConfiguratorPanel>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadioButtonList1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadioButtonList1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadioButtonList2">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadioButtonList2" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnDetailTableDataBind="RadGrid1_DetailTableDataBind" AutoGenerateHierarchy="true">
        </telerik:RadGrid>
        <!-- content end -->
        <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451