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

displaying related table data

5 Answers 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Will Ferguson
Top achievements
Rank 1
Will Ferguson asked on 29 Apr 2010, 11:35 AM
I know this is a basic question. I just can't find the answer. Please poiunt me in the right direction

i have 2 tables
Customer and towms

how do I get the townName to display in a datagrid view rather thatn the TownID

you now what I mean. I don't want to see townID  but TownName (from the towns table)

5 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 29 Apr 2010, 12:52 PM
Hello Will Ferguson,

The right way to achieve this is to use the proper view model and feed it to RadGridView e.g. do not bind to data directly , but use a proxy object to translate IDs to descriptions and bind the RadGridView to this proxy object.

Another way:
However you might harness RadGridView to do this for you.You may use the GridViewComboBoxColumn -  it has a separate ItemsSource , so you can feed it with a List of towns , set the TownName as DisplayMemberPath, set the TownID as SelectedValuePath and set the DataMemberBinding to the ID in your master table.
The column will then translate the IDs to Names for you .
In Display mode it will show a text with the translated name, and in edit mode it will show a combobox editor. You might disable the edit mode if you do not need it in your scenario.

All the best,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Will Ferguson
Top achievements
Rank 1
answered on 01 May 2010, 12:53 AM
Ok Yes I would like to do this the Best way.

I have an Edmx Entity model. In another tier.

Is there a walkthrough for me on the matter of displaying heirarchical data.
0
Pavel Pavlov
Telerik team
answered on 03 May 2010, 10:40 AM
Hi Will,

To point you in the right direction , I will need to know  a bit more - would the cell displaying the Town be editable ? In other words is it read-only , or the user should be capable of selecting a new Town ?

Regards,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Will Ferguson
Top achievements
Rank 1
answered on 03 May 2010, 11:56 PM
The town Field would not need to be editable. At most I may consider a combo box. ( a list of town names). But fo rnow I think it's best as a readonly . I'll do my editing on another "form"
0
Pavel Pavlov
Telerik team
answered on 04 May 2010, 01:59 PM
Hi Will Ferguson,

The attached sample demonstrates the simpliest possible solution with RadGridView.

It has a Locations datatable which stores the TownID.
There is a second datatable with Towns .
RadGridView is set up with a GridViewComboBoxColumn to translate the town IDs to Names.


Kind regards,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Will Ferguson
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Will Ferguson
Top achievements
Rank 1
Share this question
or