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

Parent Child Relationship

3 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 16 Dec 2010, 10:29 PM
I can not figure out how to define the relationship in such way to have the parent and child data already in the radgrid when the page is displayed.

The parent datatable contains columns: "CustomerID", "ContactName" and "Company" 
The child datatable contains columns: "CustomerID", "OrderID", "OrderDate" and "Freight"

I understand how to do this as shown in the demos but how do I accomplish this in the code behind?  I do not want to do a postback or use ajax to get the child data.

Thanks in advance

This is the aspx data:

       <telerik:RadGrid ID="RadGrid1" runat="server" Width="95%" ShowStatusBar="True"
            AutoGenerateColumns="False" PageSize="7" AllowSorting="True"
            AllowPaging="True"  
        GridLines="None"  >
            <MasterTableView Width="100%" DataKeyNames="CustomerID" AllowMultiColumnSorting="True" >
                 <DetailTables>
                    <telerik:GridTableView DataKeyNames="OrderID" Name="Orders" Width="100%">
                        <Columns>
                            <telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton"
                                DataField="OrderID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" HeaderButtonType="TextButton"
                                DataField="OrderDate" UniqueName="OrderDate" DataFormatString="{0:D}">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Freight" HeaderText="Freight" HeaderButtonType="TextButton"
                                DataField="Freight" UniqueName="Freight">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
  <ExpandCollapseColumn Visible="True"></ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" HeaderButtonType="TextButton"
                        DataField="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" HeaderButtonType="TextButton"
                        DataField="ContactName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" HeaderButtonType="TextButton"
                        DataField="CompanyName">
                    </telerik:GridBoundColumn>
                </Columns>
           </MasterTableView>
        </telerik:RadGrid

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 17 Dec 2010, 08:38 AM
Hello John,

If I understand your question correctly you can use HierarchyLoadMode.Client. This expanding to view child tables will be on client as all related data will be bound on server. You can find more details on the article bellow:
http://www.telerik.com/help/aspnet-ajax/grdhierarchyloadmodes.html

Regards,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
John
Top achievements
Rank 1
answered on 21 Dec 2010, 08:09 PM
I have been able to get the parent child to work using the DetailTableDataBind event and having HierarchyLoadMode="Client".  I am moving from Infragistics and using there controls I was able to bind the grid to a dataset that contained two tables with a data relationship defined using this method: Dim dr As DataRelation = New DataRelation("OrderTable", dc1, dc2, False) .  How or can I do this for a RadGrid wihout using the DetaiTableDataBind event?

0
Accepted
Nikolay Rusev
Telerik team
answered on 27 Dec 2010, 04:01 PM
Hello John,

I assume that you are looking for the following demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/autogeneratedhierarchy/defaultcs.aspx

Regards,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
John
Top achievements
Rank 1
Share this question
or