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.

Foreign Key Lookup when binding GGC to Business Object collection

Thread ID:

Created:

Updated:

Platform:

Replies:

40290 Jan 30,2006 08:41 PM Jan 31,2006 10:39 AM Windows Forms 4
loading
Tags: GridControl
Jay Mooney
Asked On January 30, 2006 08:41 PM

I am having problems figuring out the relations to use in order to generate a Lookup dropdown in the GGC. I was able to figure out how to do the Parent/Child relationship using the UniformChildList, but the other relationship types don''t seem to work unless binding to a DataSet. Has anyone done this before? I can post sample code if what I''m looking for is unclear. Thank you. Jay

stanleyj [Syncfusion]
Replied On January 31, 2006 05:02 AM

Hi Jay, Please refer the sample in \Syncfusion\Essential Studio\4.1.0.51\windows\Grid.Grouping.Windows\Samples\StrongTypedCollection folder. Best regards, Stanley

Jay Mooney
Replied On January 31, 2006 09:28 AM

Hi Stanley, I did refer to that sample. The sample shows you how to setup a Master/Detail relationship. But it doesn''t show you how to do a Lookup relationship. Any other suggestions?

Jay Mooney
Replied On January 31, 2006 09:33 AM

Specifically I''m looking for how to use ListItemReference or ForeignKeyReference with my business objects.

Jay Mooney
Replied On January 31, 2006 10:39 AM

I figured it out. Here''s my solution in case anyone else can benefit from it: _countries is a BindingList Country has some public fields, and a "UserId" column that is a reference to the _users collection. _users is a BindingList User has 2 fields Id and Name Step 1: Add both collections as sourceListset items for the GGC gridGroupingControl1.SourceListSet.Add(new SourceListSetEntry("COUNTRIES", _countries)); gridGroupingControl1.Engine.SourceListSet.Add(new SourceListSetEntry("USERS", _users)); Step 2: Define the GridRelationDescriptor, using a ForeignKeyReference, and setting the RelationKeys appropriately for the _users and _countries collections. GridRelationDescriptor rdLookup = new GridRelationDescriptor(); rdLookup.Name = "UsersFKLookup"; rdLookup.MappingName = "Users"; rdLookup.ChildTableName = "USERS"; rdLookup.RelationKind = RelationKind.ForeignKeyReference; rdLookup.RelationKeys.Add("UserId", "Id"); rdLookup.ChildTableDescriptor.VisibleColumns.Add("Name"); rdLookup.ChildTableDescriptor.SortedColumns.Add("Name"); rdLookup.ChildTableDescriptor.AllowEdit = false; rdLookup.ChildTableDescriptor.AllowNew = false; Step 3: Add the relation descriptor to the table''s relations. gridGroupingControl1.TableDescriptor.Relations.Add(rdLookup); Step 4: Associate the _countries collection with the GGC''s DataSource. gridGroupingControl1.DataSource = _countries;

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.

;