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

Rad Grid Heirarchichal Data

1 Answer 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sabindas
Top achievements
Rank 1
Sabindas asked on 20 Jan 2010, 01:52 PM
Dear all ,
I am facing problem with Heirachichal data grid view.
i went thorug the online sample. for bounded and unbouded grid views

with the unbounded grid
 
------------------------------------
i am facing problem for adding the chilld templte rows
GridViewTemplate template = radGridView1.MasterGridViewTemplate.ChildGridViewTemplates[0];
template.Rows.Add()

template.Rows.Add()  functionality is not  supporting. :(


with the bouded grid
--------------------------------
below given is the source code used for bouded grid

 

DataSet

 

ds = new DataSet ();  

 

 

ds.ReadXml(

@"Parent.xml");  

 

 

 

DataTable Parent = ds.Tables[0];

ds =

new DataSet();  

 

ds.ReadXml(

@"Child.xml");  

 

 

DataTable Child = ds.Tables[0]; 

 

radGridView1.AutoGenerateHierarchyFromDataSet =

true;  

 

radGridView1.MasterGridViewTemplate.AllowAddNewRow =

true;  

 

radGridView1.MasterGridViewTemplate.DataSource = Parent;

 

//setup the child template 

 

 

GridViewTemplate template = new GridViewTemplate();  

template.AllowAddNewRow =

true;  

 

template.DataSource = Child; 

 

//create the relation  

 

 

GridViewRelation relation = new GridViewRelation(radGridView1.MasterGridViewTemplate);  

relation.ChildTemplate = template;

relation.RelationName =

"ModuleID";  

 

relation.ParentColumnNames.Add(

"ModuleID");  

 

relation.ChildColumnNames.Add(

"ModuleID");  

 

radGridView1.Relations.Add(relation);

 

// Adding child template to Main Grid  

radGridView1.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);

radGridView1.AutoGenerateHierarchyFromDataSet =

true

Sample Data in Parent Table.
---------------------------------------- 

 

<

 

Table
<
ModuleID>1</ModuleID>  

 

<

 

ModuleName>Organisation</ModuleName>  

 

<

 

ArbModuleName>arbOrganisation</ArbModuleName>

 

 </

 

Table>
Sample Data in child Table
----------------------------------

 

<

 

Table>

 

 <

 

ModuleID>1</ModuleID>

 

 <

 

FormID>2</FormID>  

 

<

 

FormName>frmCountry</FormName>

 

 <

 

FormDescription>Country Details</FormDescription>

 

 <

 

FormArbDescription>Arb Country Details</FormArbDescription>

 

 </

 

Table 

The grid is displaying only the parent table data.
I didnt changed any property of the grid except in the above code

please give me a solution.

Thanking you

Sabindas K S

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 22 Jan 2010, 01:36 PM
Hi Sabindas,

For your scenario you can use this code snippet:

DataSet ds = new DataSet();
ds.ReadXml("parent.xml");
DataTable parent = ds.Tables[0];
parent.TableName = "Parent";
ds.Tables.RemoveAt(0);
 
ds = new DataSet();
ds.ReadXml("child.xml");
DataTable child = ds.Tables[0];
child.TableName = "Child";
ds.Tables.RemoveAt(0);
 
ds = new DataSet();
ds.Tables.Add(parent);
ds.Tables.Add(child);
ds.Relations.Add(parent.Columns[0], child.Columns[0]);
 
radGridView1.AutoGenerateHierarchy = true;
radGridView1.MasterGridViewTemplate.AllowAddNewRow = true;
radGridView1.DataSource = ds;
radGridView1.DataMember = "Parent";

More information about RadGridView hierarchy mode can be found here:

Binding to Hierarchical Data
Binding to Hierarchical Data Automatically
Binding to Hierarchical Data Programmatically

Kind regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Sabindas
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or