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.
AD
Administrator
Syncfusion Team
July 28, 2008 12:59 PM UTC
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?
SR
SubhaSheela R
Syncfusion Team
July 30, 2008 09:00 AM UTC
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
AD
Administrator
Syncfusion Team
July 30, 2008 02:46 PM UTC
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";
SR
SubhaSheela R
Syncfusion Team
August 5, 2008 08:32 AM UTC
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