Completed
Last Updated: 08 Jun 2015 12:52 by ADMIN
ADMIN
Hristo
Created on: 13 Feb 2015 14:46
Category: GridView
Type: Bug Report
0
FIX. RadGridView - exception when expanding the most inner level of a three level hieararchy grid with manually created templates and relations
How to Reproduce:
Source XML:
<?xml version="1.0" encoding="utf-8"?>
<grandparent Date="2014-12-17Z" Name="Grandparent" SchemaVersion="1.0" Time="04:27:07Z" xmlns="">
 <parent Name="parent1" City="Los Angeles">
   <child Name="Child1" Age="5"/>
   <child Name="Child2" Age="8"/>
 </parent>
 <parent Name="parent2" City="Chicago">
   <child Name="Child1" Age="11"/>
   <child Name="Child2" Age="15"/>
 </parent>
</grandparent>

 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            DataSet xmlDataSet = new DataSet();
            xmlDataSet.ReadXml(@"..\..\test.xml");
            GridViewTemplate parentTemplate = new GridViewTemplate();
            this.radGridView1.MasterTemplate.Templates.Add(parentTemplate);
            GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate);
            relation.ChildTemplate = parentTemplate;
            relation.RelationName = "Grandparent_Parent";
            relation.ParentColumnNames.Add("grandparent_Id");
            relation.ChildColumnNames.Add("grandparent_Id");
            radGridView1.Relations.Add(relation);
            this.radGridView1.DataSource = xmlDataSet.Tables[0];
            parentTemplate.DataSource = xmlDataSet.Tables[1];
            parentTemplate.AllowAddNewRow = false;

            GridViewTemplate childTemplate = new GridViewTemplate();

            parentTemplate.Templates.Add(childTemplate);
            GridViewRelation childRelation = new GridViewRelation(parentTemplate);

            childRelation.ChildTemplate = childTemplate;
            childRelation.RelationName = "Parent_Child";
            childRelation.ParentColumnNames.Add("parent_Id");
            childRelation.ChildColumnNames.Add("parent_Id");
            radGridView1.Relations.Add(childRelation);

            childTemplate.DataSource = xmlDataSet.Tables[2];
        }
    }

Workaround - set the data sources of the templates last, or use auto generate hierarchy:
            this.radGridView1.AutoGenerateHierarchy = true;

            DataSet xmlDataSet = new DataSet();
            xmlDataSet.ReadXml(@"..\..\test.xml");
            this.radGridView1.DataSource = xmlDataSet;
            radGridView1.DataMember = "grandparent";

            this.radGridView1.AutoGenerateHierarchy = true;
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments