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

Big picture question about DetailTableDataBind events

2 Answers 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 05 Nov 2012, 08:31 PM
What I have right now is a RadGrid populated by the NeedDataSource event.  I'm tryin to add a details level.

Do I understand correctly?  If I want to set up a RadGrid with one or more detail levels, each detail level must be separately bound in it's own DetailTableDataBind event?  (The NeedDataSource event can only provide for the top level?)

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 06 Nov 2012, 04:56 AM
Hi,

The MasterTable(Parent RadGrid) is Bound using NeedDataSource event and all the Detail Tables should be bound using DetailTableDataBind event.The main steps when binding a hierarchical grid using the DetailTableDataBind event are as follows: 

1.Create the grid, either statically or dynamically. Set the properties of the grid to provide the appearance and functionality you want. You must create and add GridTableView objects to the DetailTables collection of the MasterTableView and any detail tables that have their own nested details. 

2.Bind the master table view of the grid either declaratively or by assigning a NeedDataSource event handler to the grid. Optionally, you can assign data sources to the detail tables, which can subsequently be configured in the DetailTableDataBind event handler. 

3.Assign the DetailTableDataBind event handler to the grid. 

4.In the DetailTableDataBind event handler, assign or configure the data sources for the detail tables in the grid. You can determine which datasource should be related to the parent GridTableView by checking the Name property, DataSourceID property (when using data source controls) or DataMember property (when not using data source controls). If the DetailTableDataBind event is not handled, each detail table will be bound to the same datasource as the master table without any filtering applied on the records.

C#:
protected void RadGrid1_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
    switch (e.DetailTableView.Name)
    {
        case "Orders":
            {
               //bind first detail table
            }
 
        case "OrderDetails":
            {
                //bind second detail table
            }
    }
}

Please take a look into this help documentation.

Thanks,
Princy.
0
Boris
Top achievements
Rank 1
answered on 06 Nov 2012, 01:10 PM
It finally started making sense late yesterday...

Thanks.
Tags
Grid
Asked by
Boris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Boris
Top achievements
Rank 1
Share this question
or