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

Setting the 3rd level of hierarchy in Rad Grid View.

2 Answers 75 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Muhammad Kashif Nadeem
Top achievements
Rank 1
Muhammad Kashif Nadeem asked on 27 Jul 2009, 07:00 PM

This is the code sample to set 2 level of hierarchy in Rad Grid view.

radGridView1.DataSource = nwindDataSet.Suppliers;

GridViewTemplate template = new GridViewTemplate();
template.DataSource = nwindDataSet.Products;
radGridView1
.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);

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

I want to set it further at 3rd level in programming not in design. How can I do this?

I want this hierarchy.

- Suplier
----Product
--------Category

2 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 28 Jul 2009, 02:55 PM
Hi Muhammad Kashif Nadeem,

You can use following code snippet:


radGridView1.DataSource = nwindDataSet.Suppliers; 
 
//second level 
GridViewTemplate template = new GridViewTemplate(); 
template.DataSource = nwindDataSet.Products; 
radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.Add(template); 
 
GridViewRelation relation = new GridViewRelation(radGridView1.MasterGridViewTemplate); 
relation.ChildTemplate = template; 
relation.RelationName = "SuppliersProducts"
relation.ParentColumnNames.Add("SupplierID"); 
relation.ChildColumnNames.Add("SupplierID"); 
radGridView1.Relations.Add(relation); 
 
//third level 
GridViewTemplate template3 = new GridViewTemplate(); 
template3.DataSource = nwindDataSet.Category; 
template.ChildGridViewTemplates.Add(template3); 
 
GridViewRelation relation2 = new GridViewRelation(template); 
relation2.ChildTemplate = template3; 
relation2.RelationName = "ProductsCategory"
relation2.ParentColumnNames.Add("ProductID"); 
relation2.ChildColumnNames.Add("ProductID"); 
radGridView1.Relations.Add(relation2); 
 


Sincerely yours,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Muhammad Kashif Nadeem
Top achievements
Rank 1
answered on 02 Aug 2009, 01:19 PM
Thanks, Julian Benkov .
Tags
Development (API, general questions)
Asked by
Muhammad Kashif Nadeem
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Muhammad Kashif Nadeem
Top achievements
Rank 1
Share this question
or