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.
Unfortunately, activation email could not send to your email. Please try again.

Adding Related Tables without enforcing relations

Thread ID:

Created:

Updated:

Platform:

Replies:

35070 Sep 22,2005 04:29 AM Sep 28,2005 09:01 AM Windows Forms 5
loading
Tags: Grouping
Theo Danzfuss
Asked On September 22, 2005 04:29 AM

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

Administrator [Syncfusion]
Replied On September 22, 2005 09:10 AM

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

Theo Danzfuss
Replied On September 22, 2005 10:26 AM

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

Administrator [Syncfusion]
Replied On September 22, 2005 07:25 PM

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

Theo Danzfuss
Replied On September 28, 2005 03:20 AM

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

Administrator [Syncfusion]
Replied On September 28, 2005 09:01 AM

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

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.

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.

;