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

Need some help with foreign key references and values

Thread ID:

Created:

Updated:

Platform:

Replies:

120493 Sep 21,2015 09:02 AM UTC Nov 19,2015 04:57 PM UTC WinForms 7
loading
Tags: GridGroupingControl
Pierre Smith
Asked On September 21, 2015 09:02 AM UTC

Hi
I have a table that I has the key values in it but I want to reference data from another table with that key and there are multiple key values in table 1
So table has for instance
Client - transaction - bank
1 - 20/9/2015 - 2
the 1 and 2 I want to replace with the data in the other 2 tables
Client - transaction - bank
John - 20/9/2015 - HSBC

how can I do this I tried finding the solution in the documentation but I can not find what I am looking for

thank you


Adhikesevan Kothandaraman [Syncfusion]
Replied On September 22, 2015 12:59 PM UTC

Hi Pierre,

Thanks for your update.

To have a foreign key relation in GridGroupingControl, you need to add the GridRelationDescriptor to the table descriptor and set the RelationKind as ForeignKeyReference. Please refer to the following code example,

Code Example:

GridTableDescriptor mainTd = this.gridGroupingControl1.TableDescriptor;

GridRelationDescriptor usStatesRd = new GridRelationDescriptor();

usStatesRd.Name = "State";

usStatesRd.RelationKind = RelationKind.ForeignKeyReference;

usStatesRd.ChildTableName = "USStates";  // SourceListSet name for lookup
usStatesRd.RelationKeys.Add("State", "Key");
mainTd.Relations.Add(usStatesRd);

Please refer to the following Dashboard sample, in which we have adding the foreign key reference to the GridGroupingControl.

Sample Location:
<InstalledLocation>\Syncfusion\EssentialStudio\<VersionNo>\Windows\Grid.Grouping.Windows\Samples\Relation And Hierarchy\Foreign-Key Reference Demo\CS

Regards,
Adhi


Pierre Smith
Replied On October 14, 2015 09:23 AM UTC

Hi Adhi

I made some changes to my database . I am using Entity Framework and the table that I am using have child tables so it gets loaded automatically when I bind to that table. Now I just want to know how do I make my Child tables show up as Dropdown boxes so that the client can select them

Regards

Solai A L [Syncfusion]
Replied On October 16, 2015 01:38 AM UTC

Hi Pierre,

You can use QuerCellStyleInfo event to add a dropdown to child table cells. Please refer the code example and let us know if you have any other concerns.

Code example:

this.groupingGrid1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(groupingGrid1_QueryCellStyleInfo);

void groupingGrid1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)

        {

            if (e.TableCellIdentity.TableCellType == GridTableCellType.EmptySectionRowHeaderCell)//check the celltype of your child table and set the condition accordingly.

                e.Style.CellType = GridCellTypeName.ComboBox;

                e.Style.DataSource = list;

        }

Regards,
AL.Solai.


Pierre Smith
Replied On November 9, 2015 05:34 AM UTC

HI Al

First of this is done at runtime is there no option for design time where you can change the options to a dropdownbox and set the data source
then in the example you gave me what type of source can I use . Only a list or can do i need to use the same table as the data source and how do i bring the same table in to the source

Regards


Anish George [Syncfusion]
Replied On November 10, 2015 04:00 PM UTC


Hi Pierre,

It is not possible to access the dropdown box in GridControl while in design mode. The values can be assigned only in runtime. And the data source assigned in the combo box can be a list or of any type.

We are not quite clear with the query “how do i bring the same table in to the source”? We assume that you are asking, whether it is possible to use the same data source of the GridGroupingControl to the Dropdownbox? In that case it is possible to add the same datasource to the dropdownbox.

Please let us know whether we have misunderstood your query.

Regards,
Anish


Pierre Smith
Replied On November 18, 2015 08:46 AM UTC

Hi Anish

This is my situation . My main table has a few key references to other tables and with entity framework those tables now get pulled into the grid so you get the situation of
Key-Int , Value , Value , Key Table2 , Table2 value

so if i want to change table2 value in the grid I need to specify the Key table 2 manually. I want Key table 2 to reference the other table values with a drop down box but seeing as the table is being pulled into the grid via entity framework i was thinking of using that info

Regards
Pierre

Anish George [Syncfusion]
Replied On November 19, 2015 04:57 PM UTC

Hi Pierrre,

Sorry for the inconvenience caused.

We are quite unclear on what you are trying to achieve. I assume that you are trying to access an entity datasource into the dropdownbox which is not possible. Could you please modify the below sample which has an entity framework as datasource so that we can suggest you solution. Or you can create an incident through your Direc Trac mail ID given so that our dedicated engineers can assist you and can give you a quick solution.

Sample:
http://www.syncfusion.com/downloads/support/directtrac/general/ze/CS1194095274.zip        

Regards,
Anish

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

;