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

hierarchical grid problem

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 02 Feb 2009, 03:10 PM
Hi,
I have two datasets that I create in code..

SqlDataAdapter.Fill(dsDetails,

"RoleResponsibility")

 

SqlDataAdapter.Fill(dsDetails,

"Role")

The "Role" table in the dsDetails dataset is the master table, and the RoleResponsibility table is the child.

I have reviewed the documentation, and I am a little confused, mainly because the samples are creating tables in code.

How do you have a hierarchical view between two tables in a dataset ?

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 02 Feb 2009, 07:20 PM
Hello Peter,

Please examine the following example (it is runnable):
<telerik:RadGrid ID="RadGrid1" runat="server" Width="500px" OnDetailTableDataBind="RadGrid1_DetailTableDataBind" 
    OnNeedDataSource="RadGrid1_NeedDataSource"
    <MasterTableView DataKeyNames="ID"
        <DetailTables> 
            <telerik:GridTableView DataKeyNames="ID" Width="100%"
                <ParentTableRelation> 
                    <telerik:GridRelationFields DetailKeyField="ID" MasterKeyField="ID" /> 
                </ParentTableRelation> 
            </telerik:GridTableView> 
        </DetailTables> 
    </MasterTableView> 
</telerik:RadGrid> 

protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) 
    DataTable table = new DataTable(); 
    table.Columns.Add("ID"typeof(int)); 
    table.Columns.Add("Car"typeof(string)); 
    table.Rows.Add(1, "HONDA"); 
    table.Rows.Add(2, "LANCIA"); 
    e.DetailTableView.DataSource = table; 
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
    DataTable table = new DataTable(); 
    table.Columns.Add("ID"typeof(int)); 
    table.Columns.Add("Name"typeof(string)); 
    table.Rows.Add(1, "Peter"); 
    table.Rows.Add(2, "John"); 
    RadGrid1.DataSource = table; 

I hope this helps.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or