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

Can I display the Hierarchical view like following XML file?

1 Answer 75 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Z asked on 06 Mar 2009, 05:25 PM
<?xml version="1.0" encoding="utf-8"?>  
  <CreateDate>01/03/2009 12:23:34</CreateDate> 
           <PartDescription>Part Number 1 has expection</PartDescription> 
           <PartDescription>No Part available</PartDescription> 
  <CreateDate>01/01/2001 11:00:00</CreateDate> 
           <PartDescription>Part Number3 has expection</PartDescription> 
           <PartDescription>4 Part available</PartDescription> 
the Invoice table to part table is many to many
so  table diagram is  "Invioce" -> "InvoiceParts" ->"Parts"
any sample codes how to implement it?

here is my source code
 Dim mO As New XMLOperater  
        grdvewCurrentParts.DataSource = mO.XMLToDataSet("C:\xmlfile.xml").Tables(0)  
        Dim template As Telerik.WinControls.UI.GridViewTemplate = New Telerik.WinControls.UI.GridViewTemplate  
        template.DataSource = mO.XMLToDataSet("C:\xmlfile.xml").Tables(1)  
        Dim template2 As Telerik.WinControls.UI.GridViewTemplate = New Telerik.WinControls.UI.GridViewTemplate  
        template2.DataSource = mO.XMLToDataSet("C:\xmlfile.xml").Tables(2)  
        Dim relation As GridViewRelation = New GridViewRelation(grdvewCurrentParts.MasterGridViewTemplate)  
        Dim relation2 As GridViewRelation = New GridViewRelation(grdvewCurrentParts.MasterGridViewTemplate.ChildGridViewTemplates(template))  
        relation.ChildTemplate = template  
        relation2.ChildTemplate = template2  
        relation.ChildColumnNames.Add("Invoice_Id")               relation2.ParentColumnNames.Add("Parts_Id")  
thank you very much!

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 10 Mar 2009, 09:35 PM
Hi Z,

Thank you for contacting us.

We do not support many-to-many relations, but just one-to-many and one-to-one. Since your xml data is one-to-many, it therefore can be presented. You have essentially used an elimination. Please refer to this external resource.

The DataSet created by ReadXml method contains 3 tables which you can avoid easily by skipping the second table and using the first and the third ones only. Here is sample code for your xml:

 private void Form1_Load(object sender, EventArgs e) 
            DataSet xmlDataSet = new DataSet(); 
            GridViewTemplate partsTemplate = new GridViewTemplate(); 
            GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterGridViewTemplate); 
            relation.ChildTemplate = partsTemplate; 
            relation.RelationName = "Invoices_Parts"
            this.radGridView1.DataSource = xmlDataSet.Tables[0]; 
            partsTemplate.DataSource = xmlDataSet.Tables[2]; 

The Invoice_Id and Parts_Id columns were added automatically to the tables by ReadXml method. I checked what was created and set all the parameters respectively in the Form_Load event handler.

I will update our documentation with topics about loading xml. Do not hesitate to write me back if you have further questions.

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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question