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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add relationship using multiple keys

Thread ID:

Created:

Updated:

Platform:

Replies:

119891 Aug 11,2015 07:22 AM UTC Aug 14,2015 08:47 AM UTC WinForms 3
loading
Tags: GridGroupingControl
Rasika
Asked On August 11, 2015 07:22 AM UTC

Hello,
I am using Grid grouping control for a parent-child relationship.
I want to add relationship using 2 key pairs. I have Employee_id and Year in both data tables of a data set.
I don't want to show different tables to the parent table for those keys.
Is there any method for this?


Thank you and Regards,
Rasika

Mahendran Annamalai [Syncfusion]
Replied On August 12, 2015 07:21 AM UTC

Hi Rasika,

Thanks for using syncfusion products.

Generally, the parent-child relation can be associated by using a primary key (only one Unique column). It seems your requirement is to have two common keys which is not possible as per the current architecture of GridGroupingControl  but you can try out with the followings and choose your needed requirement.

Using ForeignKey relation
You can use foreign key relations to add your needed keys.

GridRelationDescriptor usStatesRd = new GridRelationDescriptor();

usStatesRd.Name = "State";

usStatesRd.RelationKind = RelationKind.ForeignKeyReference;

usStatesRd.ChildTableName = "USStates"// SourceListSet name for lookup

usStatesRd.RelationKeys.Add("State", "Key");


A sample for foreign key demo is located in our dashboard,
Location : C:\Users\.... \AppData\Local\Syncfusion\EssentialStudio\\”InstalledVersion”\Windows\Grid.Grouping.Windows\Samples\Relation And Hierarchy\Foreign-Key Reference Demo


Using Primary key with grouping
Along with primary key (“Employee_ID”) setting, you can group the another column (“Year”) to show the records in the separated view.

GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();

childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable"// same as SourceListSetEntry.Name for grandChhildTable (see below)

childToGrandChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;

childToGrandChildRelationDescriptor.RelationKeys.Add("childID", "ChildID");


// Add relation to ChildTable

parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);


You can make use of the below dashboard sample with the below code snippet (Grouping)

Location : C:\Users\....\AppData\Local\Syncfusion\EssentialStudio\”InstalledVersion”\Windows\Grid.Grouping.Windows\Samples\Relation And Hierarchy\Related Master Details Demo


//Adding column to the Group.
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("Column Name");



If the above ways doesn’t meet the exact requirement, please provide a sample image of your requirement. That would be helpful to serve you better.

Thanks,
Mahendran.A

Rasika
Replied On August 13, 2015 11:38 AM UTC

Hello,
Thank you for the reply.
It meets the requirement.

Thanks and Regards,
Rasika

Mahendran Annamalai [Syncfusion]
Replied On August 14, 2015 08:47 AM UTC

Hi Rasika,

Thanks for your update.
Please let us know if you need further assistance.

Regards,
Mahendran.A

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.

Warning Icon 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.Close Icon

;