We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Add relation using multiple key pairs

Thread ID:

Created:

Updated:

Platform:

Replies:

118125 Feb 3,2015 07:47 AM Feb 4,2015 01:27 PM Windows Forms 1
loading
Tags: GridGroupingControl
Rasika
Asked On February 3, 2015 07:47 AM

Hello,
I want to create Parent-Child relationship using multiple key pairs.
I have 2 tables as parent and child table.
Is there any possibility to add 4 relation keys (2 from parent table and 2 from child table) in a single relation descriptor?

Thanks and regards,
Rasika.

Muthukumar Kalyanasundaram [Syncfusion]
Replied On February 4, 2015 01:27 PM

Hi Rasika,

 

Thank you for your interest in Syncfusion products.

 

If you want to create Parent-Child relationship using multiple key pairs in GridGroupingControl, you can add a multiple child table to single parent table (parent-child relation). In grid, at a time single datasource can be  can referred. Please refer the code,

 

Code:

DataTable parentTable = GetParentTable();

DataTable childTable1 = GetChildTable1();

DataTable childTable2 = GetChildTable2();

 

GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();

parentToChildRelationDescriptor.ChildTableName = "MyChildTable1";

parentToChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;

parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID");

 

GridRelationDescriptor ptc = new GridRelationDescriptor();

ptc.ChildTableName = "MyChildTable2";

ptc.RelationKind = RelationKind.RelatedMasterDetails;

ptc.RelationKeys.Add("parentID", "ParentID");

 

// Add relation to ParentTable

gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

gridGroupingControl1.TableDescriptor.Relations.Add(ptc);

 

// Register any DataTable/IList with SourceListSet, so that RelationDescriptor can resolve the name

this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);

this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable1", childTable1);

this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable2", childTable2);

 

this.gridGroupingControl1.DataSource = parentTable;

 

Please let us know if you have any concern.

 

Regards,

Muthukumar k


Attachment: Related_Master_Details_Demo_79b7639a.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;