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 relationship using multiple keys

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

3 Replies

MA Mahendran Annamalai Syncfusion Team 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


RA Rasika August 13, 2015 11:38 AM UTC

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

Thanks and Regards,
Rasika


MA Mahendran Annamalai Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon