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

Foreign Key Columns in GridGroupingControl

Thread ID:





13338 Apr 27,2004 02:53 AM UTC Apr 27,2004 09:18 PM UTC WinForms 4
Tags: Grouping
Administrator [Syncfusion]
Asked On April 27, 2004 02:53 AM UTC

I''m trying to convert some code from GridDataBoundGrid to GridGroupingControl. I haven''t yet been able to figure out how to deal with foreign keys (either for display or for grouping, though Display is far more important). Currently, I do things as per p. 113 of the Grid manual: GridBoundColumn foreignkeycol = grid.Binder.InternalColumns[0]; foreignkeycol.StyleInfo.CellType = "Static"; foreignkeycol.StyleInfo.DataSource = ForeignTable; foreignkeycol.StyleInfo.DisplayMember = "Foo"; foreignkeycol.StyleInfo.ValueMember = "Id"; [I''d also like to be able to get an event before it does the lookup (does QueryStyleInfo get called before it does this mapping?) so I can ensure the value is in my DataTable. But that''s once things are going.] Thanks, Dan

Administrator [Syncfusion]
Replied On April 27, 2004 10:00 AM UTC

Hi Dan, here are some code snippets from the HierarchyView sample that display a foreign key table in a dropdown list: gridColumnDescriptor5.Appearance.AnyRecordFieldCell.CellType = "GridListControl"; gridColumnDescriptor5.Appearance.AnyRecordFieldCell.DataSource = this.shippersDataSet1.Shippers; gridColumnDescriptor5.Appearance.AnyRecordFieldCell.DisplayMember = "CompanyName"; gridColumnDescriptor5.Appearance.AnyRecordFieldCell.ValueMember = "ShipperID"; gridColumnDescriptor5.Appearance.AnyRecordFieldCell.HorizontalAlignment = Syncfusion.Windows.Forms.Grid.GridHorizontalAlignment.Left; gridColumnDescriptor5.MappingName = "ShipVia"; gridColumnDescriptor5.Width = 158; gridRelationDescriptor1.ChildTableDescriptor.Columns.AddRange(new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor[] { new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("OrderID"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("CustomerID"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("EmployeeID"), gridColumnDescriptor5, new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("Freight"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("ShipName"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("ShipAddress"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("ShipCity"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("ShipRegion"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("ShipPostalCode"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("ShipCountry")}); In that sample, the foreign key table is in a separate dataset which is the best way to do it. There is also another alternative that is a bit more complicate and I am not sure how well that works for you. We will add support for foreign key relations in future, but the sample gives a first glimpse how this will look like. It is implemented using TableDescriptor_QueryValue and TableDescriptor_SaveValue. It shows data from a foreign table as columns in the records of the main table. This is the sample: ForeignKeyGrid_938.zip Stefan

Administrator [Syncfusion]
Replied On April 27, 2004 07:34 PM UTC

Thank you. What''s the advntage of having it in a separate dataset? (In my application, this is rather difficult.)

Administrator [Syncfusion]
Replied On April 27, 2004 08:37 PM UTC

If both tables are in the same dataset and there is a relation set up between the two tables the ADO dataset tries to join both tables into a dataview and that gets really large. If the two tables have no relation setup between them, then it should normally be ok if the table is in the same dataset. You could give it a try and only if you run into problem then try to separate the table into a different dataset. Stefan

Administrator [Syncfusion]
Replied On April 27, 2004 09:18 PM UTC

Thanks for the warning (I do have a relation between them). So, it will do the join whenever I set a DataSource for a particular column (even if I''m just using a Static cell type?) I think I''ll use QueryValue until there''s full support.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon