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

help with heirarchical grid

3 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 21 Jan 2009, 02:36 AM
I just downloaded the trial and I'm trying to display heirarchical data. I've gone through the examples but no luck. The best I can do is display the master row with the plus sign but when I click the plus sign I don't see the details.

I'm using a stored procedure to populate my dataset. It returns two tables. Table[0] is the master and Table[1] is the detail.

I've tried the following two examples. Any help would be apprecieated.

 

Example 1.

dataAdapter.Fill(myDataSet);

myDataSet.Tables[0].TableName = "workorder";
myDataSet.Tables[1].TableName = "details";

DataRelation dr = new DataRelation("workorders",
   myDataSet.Tables[0].Columns["WorkOrderId"],
   myDataSet.Tables[1].Columns["WorkOrderId"]);
DataSet.Relations.Add(dr);

radGridView1.AutoGenerateHierarchy = true;
radGridView1.DataSource = myDataSet;
radGridView1.DataMember = "workorder";

Example 2. 

radGridView1.DataSource = myDataSet.Tables[0];

GridViewTemplate template = new GridViewTemplate();
template.DataSource = myDataSet.Tables[1];
radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);

GridViewRelation relation = new GridViewRelation(radGridView1.MasterGridViewTemplate);
relation.ChildTemplate = template;
relation.RelationName = "workorders";
relation.ParentColumnNames.Add("WorkOrderId");
relation.ChildColumnNames.Add("WorkOrderId");
radGridView1.Relations.Add(relation);

3 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 21 Jan 2009, 12:34 PM
Hi Mike,

Thank you for contacting us. Please see our Hierarchical Data tutorial in our online documentation. The tutorial is available here.

Please write again if you need further assistance.

Sincerely yours,
Victor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike
Top achievements
Rank 1
answered on 21 Jan 2009, 02:32 PM
Victor,

Yes, the tutorial is where I got the code from in my examples. For some reason I can't get it to work. I thought it might be something simple that I'm overlooking and that's the reason I posted my examples. is there additional information I can provide to help diagnose the problem? Thanks.
0
Victor
Telerik team
answered on 23 Jan 2009, 06:47 PM
Hi Mike,

Thanks for writing.
I found an easier solution than the help tutorial. Here is what you need to do.
1. Create a RadGridView.
2. Add a DataSet with it's tables (I suggest using the Visual Studio wizard).
3. Fill the tables with a TableAdapter.
4. Set RadGridView's AutoGenerateHierarchy property to true.
5. Set the RadGridView's DataSource property to the dataset.
6. Set the RadGridView's DataMemeber property to the name of one of the tables.
I have attached a sample application showcase the points. It's really short. Everything is done in the Form's OnLoad event.
I hope this is helpful to you. Please write again if you have other questions or issues.

Greetings,
Victor
the Telerik team

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