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

GridRelationFields when primary key is compound

4 Answers 150 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Russell
Top achievements
Rank 1
David Russell asked on 22 May 2010, 01:59 PM

When there is a single column relating two tables defining GridRelationFields is straight forward:

GridRelationFields rf = new GridRelationFields();
rf.MasterKeyField = "col1";
rf.DetailKeyField = "col1";
tvProtocols.ParentTableRelation.Add(rf); 

However, how do you define a GridRelationFields when the keys are compound, such as:

GridRelationFields rf = new GridRelationFields();
rf.MasterKeyField = "col1,col2,col3";
rf.DetailKeyField = "col1,col2,col3";
tvProtocols.ParentTableRelation.Add(rf); 

This is not uncommon.

Must I create an autoincremented column in the parent table and then rely only upon that in the child table?

4 Answers, 1 is accepted

Sort by
0
David Russell
Top achievements
Rank 1
answered on 22 May 2010, 11:06 PM
I went ahead and modified my database schema to yield a single column join.

However, I notice the function is called ParentTableRelation.Add() - does that mean the answer to my original question was simply to Add() the additional columns?

Thanks
0
Mira
Telerik team
answered on 27 May 2010, 08:26 AM
Hello David,

Every GridRelationFields object should have only one field name for DetailKeyField and MasterKeyField. For data relationships that are based on multiple fields, add multiple GridRelationFields objects to the ParentTableRelation collection:
GridRelationFields rf1 = new GridRelationFields();
rf1.MasterKeyField = "col1";
rf1.DetailKeyField = "col1";
tvProtocols.ParentTableRelation.Add(rf1);
GridRelationFields rf2 = new GridRelationFields();
rf2.MasterKeyField = "col2";
rf2.DetailKeyField = "col2";
tvProtocols.ParentTableRelation.Add(rf2);
GridRelationFields rf3 = new GridRelationFields();
rf.MasterKeyField = "col3";
rf.DetailKeyField = "col3";
tvProtocols.ParentTableRelation.Add(rf3);

I hope this helps.

Greetings,
Mira
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Carlos Rodriguez
Top achievements
Rank 1
answered on 05 Apr 2011, 09:22 PM
I have a problem with that code. When I add the link, it gives me Javascript error. The following link shows a picture of the error:

http://www.subirimagenes.com/otros-imageerror-6209976.html
0
Mira
Telerik team
answered on 08 Apr 2011, 11:03 AM
Hello Carlos,

Based on the supplied information, it is hard to determine what is causing the error.
Please open a formal support ticket and send us a small working project, demonstrating your full setup and showing the unwanted behavior.
We will debug it locally and get back to you.

Thank you in advance for the cooperation.

Kind regards,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
David Russell
Top achievements
Rank 1
Answers by
David Russell
Top achievements
Rank 1
Mira
Telerik team
Carlos Rodriguez
Top achievements
Rank 1
Share this question
or