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

3 posts, 0 answers
  1. Muhammad Kashif Nadeem
    Muhammad Kashif Nadeem avatar
    2 posts
    Member since:
    Jun 2012

    Posted 27 Jul 2009 Link to this post

    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. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 28 Jul 2009 Link to this post

    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.
  3. DevCraft banner
  4. Muhammad Kashif Nadeem
    Muhammad Kashif Nadeem avatar
    2 posts
    Member since:
    Jun 2012

    Posted 02 Aug 2009 Link to this post

    Thanks, Julian Benkov .
Back to Top