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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridGroupingControl: Problem when using foreign key reference functionality

Thread ID:

Created:

Updated:

Platform:

Replies:

48696 Sep 1,2006 03:53 PM UTC Sep 5,2006 12:32 PM UTC WinForms 3
loading
Tags: GridControl
Konstantin Babiy
Asked On September 1, 2006 03:53 PM UTC

I want to change foreign key reference in my table by values from referenced table and display referenced table.

My sample is taken from Syncfusion Grid.Grouping samples. It tries to do functionality, implemented above, but problem is that each foreign key column is multipled by referenced table column count (every referenced table separate column is displayed in each of them). I need to have some value from the referenced table displayed instead of foreign key value.

Here is the code sample I used:

DataTable dataTable = new DataTable();
dataTable.TableName = "TestTable";
dataTable.Columns.Add("Key", typeof(string));
dataTable.Columns.Add("Name", typeof(string));
DataColumn column=dataTable.Columns.Add("Name2", typeof(string));


//dataTable.Columns[0].
// and then add a few rows:
for ( int i=1; i < 10000; i++ )
{
DataRow newRow=dataTable.NewRow();
dataTable.Rows.Add(newRow);
newRow[0] = i; //Key
newRow[1] = "Hipopotamus"+i.ToString();
newRow[2] = "Monkey" + i.ToString();
}
_dataSet.Tables.Add(dataTable);

GridTable gridTable = _gridGrouping.GetTable("ENDOTRACHIAL_ADAPTER");
GridTableDescriptor tableDescriptor = gridTable.TableDescriptor;
_gridGrouping.Engine.SourceListSet.Add("TestTable",dataTable);

GridRelationDescriptor stringFieldRd = new GridRelationDescriptor();
stringFieldRd.Name = "DisplayField";
stringFieldRd.RelationKind = RelationKind.ForeignKeyReference;
stringFieldRd.ChildTableName = "TestTable"; // SourceListSet name for lookup
stringFieldRd.RelationKeys.Add("DIAMETER_id", "Key");
stringFieldRd.ChildTableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.Beige;
//stringFieldRd.ChildTableDescriptor.VisibleColumns.Add("Key");
//stringFieldRd.ChildTableDescriptor.VisibleColumns.Add("Name");
//stringFieldRd.ChildTableDescriptor.VisibleColumns.Add("Name2");
//stringFieldRd.ChildTableDescriptor.SortedColumns.Add("Name");
stringFieldRd.ChildTableDescriptor.AllowEdit = false;
stringFieldRd.ChildTableDescriptor.AllowNew = false; // Make pencil icon disappear, users can''t modify states.
tableDescriptor.Relations.Add(stringFieldRd);

Administrator [Syncfusion]
Replied On September 2, 2006 11:14 PM UTC

I do not understand what you are describing as not working for you. Here is a sample based on the code you showed. What do you want to see different in the sample?

http://www.syncfusion.com/Support/user/uploads/WrapTextGGC_3fdcc6f1.zip

Vitaliy
Replied On September 4, 2006 10:11 AM UTC


In grid it is necessary to display only one field from table "TestTable" ("Name" or "Name2")...

Administrator [Syncfusion]
Replied On September 5, 2006 12:32 PM UTC

No. The sample in the previous post displays both the Name and Name2 columns.

By Default, all columns in the lookup table (except the actual mapped indexed column) appear in the main grid. You have to explicilty hide the ones you do not want to see.

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.

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

;