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

[Solved] Column Value Lookup

2 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jim
Top achievements
Rank 1
Jim asked on 14 Aug 2009, 03:23 PM

I have some fairly simple data, the following is an example:

public class State  
{  
    public int StateID { get; set; }  
    public string StateName { get; set; }  
}  
 
public class Location  
{  
    public string City { get; set; }  
    public int StateID  { get; set; }  
    public string ZipCode { get; set; }  

My Grid is pretty simple with:
<grid:RadGridView AutoGenerateColumns="False"   
                  x:Name="cGrid" > 
 
    <grid:RadGridView.Columns> 
        <grid:GridViewDataColumn HeaderText="City"   
                                 DataMemberBinding="{Binding City}" /> 
        <grid:GridViewDataColumn HeaderText="State"   
                                 DataMemberBinding="{Binding StateID}" /> 
        <grid:GridViewDataColumn HeaderText="ZipCode"   
                                 DataMemberBinding="{Binding ZipCode}" /> 
    </grid:RadGridView.Columns> 
</grid:RadGridView> 

How can I modify the 2nd column (state) so that when the grid is filtered / grouped I don't see the StateID rather I see a value that has been retrieved from a State collection?

I have tried a number of methods (including DataMemberBinding={Binding StateID, Converter...})

The only solution I that achieves all of my desired results is to actually create a new object (LocationModel) e.g.

 
public class LocationModel  
{  
    public string City { get; set; }  
    public int StateID { get; set; }  
    public string StateName { get; set; }  
    public string ZipCode { get; set; }  

I can't imagine this is a new conversation, but I have not been successful in finding and answer.

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 17 Aug 2009, 08:29 AM

Hello Jim,
There have been a few requests from other clients for this  functionality.
We are working towards providing such behavior of the RadGridView. You can see it in action within a week . Please check the latest internal build  the next Friday . Meanwhile your approach seems to be  the only possible descent solution with the current version.

Regards,

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.
0
Jim
Top achievements
Rank 1
answered on 17 Aug 2009, 01:39 PM
Hi Pavel -

I really appreciate your honesty about that as it will save me from banging my head against the wall. 

To the extent that you almost have a solution this suggestion is probably too late in coming, but for me the most obvious thing would be to more fully support the Binding syntax on DataMemberBinding.  When I was initially confronted with the problem I approached it the same way I do with other controls. 

The syntax that I was expecting to work was DataMemberBinding={Binding Path=StateID, Converter={StaticResource StateConverter}}

Jim
Tags
GridView
Asked by
Jim
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Jim
Top achievements
Rank 1
Share this question
or