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.

GridGroupingControl Relations

Thread ID:

Created:

Updated:

Platform:

Replies:

75481 Jul 28,2008 08:28 AM Aug 5,2008 04:32 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 28, 2008 08:28 AM

Hi,

I'm new to Syncfusion and was trying out some stuff. But i keep having problems with filling my grid. I already tried some stuff i read on the forum, but it still doesn't work.

So what do I have:
I got a DataSet _data
with 2 DataTables named Table1 and Table2
Table1 has 1 column named T1_A which i made my primary Key
Table2 has 3 columns names T2_A, T2_B and T3_C

What I would like is to have Table2 data in my grid. And for Table2.T2_B i want a combobox like thing with data from Table1.T1_A in which the correct value is selected.


This are the things I did:

grdAircraftRegistr.Engine.SourceListSet.Add("Table2", _data.Tables["Table2"]); grdAircraftRegistr.Engine.SourceListSet.Add("Table1", _data.Tables["Table1"]);

GridRelationDescriptor rdLookup = new GridRelationDescriptor();
rdLookup.Name = "fkLookup";
rdLookup.ChildTableName = "Table1";
rdLookup.RelationKind = Syncfusion.Grouping.RelationKind.ForeignKeyReference;
rdLookup.RelationKeys.Add("T2_B", "T1_A");
rdLookup.ChildTableDescriptor.VisibleColumns.Add("T1_A"); rdLookup.ChildTableDescriptor.SortedColumns.Add("T1_A");
rdLookup.ChildTableDescriptor.AllowEdit = false; rdLookup.ChildTableDescriptor.AllowNew = false;

grdAircraftRegistr.TableDescriptor.Relations.Add(rdLookup);

grdAircraftRegistr.DataSource = _data.Tables["Table2"];


I do not see a column in the grid for Table2.T2_B data. The other fields are visible.







Administrator [Syncfusion]
Replied On July 28, 2008 08:59 AM

Ok, so I managed to have a combobox.
But this is not filled and at the end of the gridcolumns.

i used
rdLookup.RelationKeys.Add("T1_A", "T2_B");
iso
rdLookup.RelationKeys.Add("T2_B", "T1_A");

But why is this combo not filled with my data from Table1?
How do i set this in the column where T2_B is shown?





SubhaSheela R [Syncfusion]
Replied On July 30, 2008 05:00 AM

Hi EDW,

Thanks for your interest in Syncfusion products.

You can refer our shipped browser sample that discusses about foreign key relations.

Here is the path:

{InstallationDrive}\Documents and Settings\{UserName}\My Documents\Syncfusion\EssentialStudio\6.3.0.25\Windows\Grid.Grouping.Windows\Samples\2.0\RelationsAndHierarchy\ForeignKeyReference\CS

Please let me know if it helps.

Regards,
Subhasheela R


Administrator [Syncfusion]
Replied On July 30, 2008 10:46 AM

Nope, that strategy did not work.
But it did work in this way:

grd.DataSource = _data.Tables["Table2"];

GridTableDescriptor tableDesc = grd.TableDescriptor; tableDesc.Columns["T2_B"].Appearance.AnyRecordFieldCell.CellType = "ComboBox"; tableDesc.Columns["T2_B"].Appearance.AnyRecordFieldCell.DataSource = _data.Tables["Table1"]; tableDesc.Columns["T2_B"].Appearance.AnyRecordFieldCell.DisplayMember = "T1_A"; tableDesc.Columns["T2_B"].Appearance.AnyRecordFieldCell.ValueMember = "T1_A";


SubhaSheela R [Syncfusion]
Replied On August 5, 2008 04:32 AM

Hi EDW,

Thanks for your update.

We are glad to know that you got solution. Please let me know if you need any further technical assistance.

Regards,
Subhasheela R


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.

;