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

Adding Related Tables without enforcing relations

Hi, I would like to know if there is a way to Add related Tables to a grid grouping control without having to Add a Relation? My scenario is I have to show a related grid for data that relate through a related table - that is I dont have a Foreign Key in my Child Table that directly relates to a Primary Key in my Parent Table. I have an intermediate table that links the two tables together. Any ideas how I would solve this using the GridGroupingControl? Regards. Theo Danzfuss

5 Replies

AD Administrator Syncfusion Team September 22, 2005 01:10 PM UTC

Hi Theo, You can see the ManualRelations sample in GridGroupingControl of the syncfusion products for the implementation you are looking for. Regards, Leo.


TD Theo Danzfuss September 22, 2005 02:26 PM UTC

I had a look at the example - but the problem is you have a scenario where there is a Foreign Key in the Child Table and a Primary Key in the Parent Table. I dont have this luxury! My tables relate through an intermediate table(an indirect reference). This means that my relationship is not of type RelationKind.RelatedMasterDetails it is a Many-to-Many- Relationship that I must show as a Related(one-to-many) view. Can I do this by Manully creating a Group OR should I rather create an intermediate Table that does have a RelatedMasterDetail relationship? TD TD


AD Administrator Syncfusion Team September 22, 2005 11:25 PM UTC

Hi Theo, you need to somehow structure your data such that it will fit into a nested table structure. Adding groups manully is not possible. You need to create an intermediate Table that does have a RelatedMasterDetail relationship. Or check out also the ProductRatings example. It shows a m:n relation when you group by rating. Products can have multiple ratings by different customers and when you group by rating the product can appear in more than one category. Another way to tackle the problem would be to use a ForeignKeyKeyWords relation. Check out the EmployeeTerritories relation (when you toggled the combobox value at the bottom of the form) in the EmployeeTerritoryOrder example. It lets you display a related table as a dropdown. Stefan >I had a look at the example - but the problem is you have a scenario where there is a Foreign Key in the Child Table and a Primary Key in the Parent Table. I dont have this luxury! My tables relate through an intermediate table(an indirect reference). This means that my relationship is not of type RelationKind.RelatedMasterDetails it is a Many-to-Many- Relationship that I must show as a Related(one-to-many) view. Can I do this by Manully creating a Group OR should I rather create an intermediate Table that does have a RelatedMasterDetail relationship? > >TD > >TD


TD Theo Danzfuss September 28, 2005 07:20 AM UTC

Hi, I followed your advice and now populate an intermediate table - this enables me to set up a Parent-Child relationship. The correct Data is displayed in the grid, but I have two problems: 1) The related table doesn''t have an empty newrow 2) When I click on a cell in the related grid the following message is printed in my debug windows: "Invalid state: IsInMoveTo returns false" What am I doing wrong? If you could maybe just explain to me when&why that message gets printed. Thanx Theo Danzfuss


AD Administrator Syncfusion Team September 28, 2005 01:01 PM UTC

Hi Theo, 1) The grid checks the AllowNew setting and also the following settings on the related list: public bool SourceListAllowNew { get { return this.sourceList != null && !this.sourceList.IsFixedSize || this.bindingList != null && this.bindingList.AllowNew; } } Make sure IsFixedSize is false. Also, make sure NestedGroupOptions.ShowAddNewRecordBeforeDetails is true. 2) This is hard to guess what is going wrong here. The message indicates that from somewhere in the grid it tried to access one of the properties: CurrentCell.MoveToRowIndex or CurrentCell.MoveToColIndex. But at the time the properties were accessed MoveTo was not called on the CurrentCell (e.g. if you call these properties after MoveTo returned). If you do not see any wrong behavior in the grid you can ignore the warning. It could be just the order how the current cell state is loaded from/to the GridChildTable and not affect your grid. If you have source code you can set a break point in the GridCurrentCell where it displays that warning. It''s best if you could upload a sample project. I can then debug into it. Stefan >Hi, > >I followed your advice and now populate an intermediate table - this enables me to set up a Parent-Child relationship. >The correct Data is displayed in the grid, but I have two problems: > >1) The related table doesn''t have an empty newrow >2) When I click on a cell in the related grid the following message is printed in my debug windows: "Invalid state: IsInMoveTo returns false" > >What am I doing wrong? If you could maybe just explain to me when&why that message gets printed. > >Thanx >Theo Danzfuss

Loader.
Live Chat Icon For mobile
Up arrow icon