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. Image for the cookie policy date

Add relation using multiple key pairs

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.

1 Reply

MK Muthukumar Kalyanasundaram Syncfusion Team February 4, 2015 06:27 PM UTC

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

Loader.
Up arrow icon