This is a migrated thread and some comments may be shown as answers.

How to handle foreign keys in RadGridView

4 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kranthi
Top achievements
Rank 1
Kranthi asked on 18 Aug 2009, 06:29 AM
Hello Telerik team,

I am using telerik radgridview in one of my WPF application. When i am binding Itemsource property i am binding a object which has foreign key columns, now in radgridview column i am getting the foreign key ID values as expected.

For example:

Binding Table Colums:
TableID
Name
Description
ForeignKeyTableID (FK)

Foreign key table:
ForeignKeyTableID
Value




Now i want to display the value of the foreign key rather than the id value, as id doesn't make any sense to display. What would be the efficient way to do this. I am thinking of using converter while binding, but it would be heavy as i will be working on thousands of records in radgrid.

Looking for a best and efficient way to handle this...

Thanks,
Kranthi

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 19 Aug 2009, 07:10 AM
Hello Kranthi,

You can safely use IValueConverter to achieve this. The grid rows are UI virtual and only converters in view-port will be executed.

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Kranthi
Top achievements
Rank 1
answered on 22 Aug 2009, 11:30 AM
Yes i can use valueconverters, but in my case, i have around 25 to 30 radgrids, and each grid consists of at least one foerign key to display.

If i start creating Ivalueconverter for each i need to create a IValueConverter for each table. Is there any way that i can make the Ivalue converter generic such that i can use it for different objects(tables)
0
ManniAT
Top achievements
Rank 2
answered on 22 Aug 2009, 12:56 PM
Hi Kranthi,

you say you bind "objects". This could mean a lot.
And since you can access the Value of the "linked table" via a converter it should also be possible to access this value in property of you "base table object" something like
public string FKTableValue {
  get { return(ResolveFKValue(ForeignKeyTableID)); }
}

Regards

Manfred
0
Pavel Pavlov
Telerik team
answered on 25 Aug 2009, 12:47 PM

Hello Kranthi,

Just an idea - The GridViewComboBoxColumn has a built in feature to translate foreign keys into their corresponding string representations (even when not in edit mode and when the combo editor is hidden).

I am not sure if GridViewComboBoxColumn is applicable in your case , but if you set the column specific properties ( itemssource, displaymemberpath, selectedvaluepath etc)  you may have this behavior 'for free'.

Sincerely yours,

Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Kranthi
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Kranthi
Top achievements
Rank 1
ManniAT
Top achievements
Rank 2
Pavel Pavlov
Telerik team
Share this question
or