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

How to access the value of the DisplayMemberPath of a ComboBox Column from a calculated field

2 Answers 108 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jonx
Top achievements
Rank 2
Jonx asked on 28 Jun 2010, 09:24 PM
Hello,
I base my question on the following help entry to illustrate my problem:
http://www.telerik.com/help/silverlight/radgridview-columns-column-types-combobox-column.html

I'm using RIA WCF Services in case it helps...

You got the following grid:

Country, wth the combobox, FirstName, LastName, Origin.

What I want is display in the Origin column the result of a computed value.

For exemple, I would display "Fernando Alonso is from Spain" once I selected spain in the first column using the combobox.
This should work local, no server roundtrip...

I'm using Presentation Model. My Class on the server is for example:
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.ServiceModel.DomainServices.Server;  
using System.ComponentModel.DataAnnotations;  
  
namespace MyWeb  
{  
    public class MyPresentationModel  
    {  
        [Key]  
        public int MyID { getset; }  
  
        public string FirstName { getset; }  
  
        public string LastName { getset; }  
    }  
}  

And on my local silverlight project I add the calculated field:
using System;   
using System.Collections.Generic;   
using System.Linq;   
using System.ServiceModel.DomainServices.Client;   
   
namespace MyWeb   
{   
    public partial class MyPresentationModel : Entity   
    {   
        public string Origin   
        {   
            get   
            {  
                string country = ???; //how to get the country from the country ID???  
                string origin = String.Format("{0} {1} is from {2}."this.FirstName, this.LastName, country);   
                return origin;   
            }   
        }   
    }   
}   

Of course this is just a simple sample to illustrate my problem. My object is much more complicated.

But short said, this is my problem. How to access to those values... Hoppefully there is a simple solution as I've been struggling with this for a couple of days now...

Thank you for your help...
John.



2 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 01 Jul 2010, 01:38 PM
Hello John,

I am afraid this would be hard to achieve. RadGridView makes all the lookup conversion from Value to DisplayValue at the UI level .

Having a reference in your business object( e.g. MyWEeb)  to RadGridView would not be a nice solution.
I would recommend to write your own method in the MyWeb object to convert from value to display value without refering to the RadGridView.

Best wishes,
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
Jonx
Top achievements
Rank 2
answered on 01 Jul 2010, 04:13 PM
ok, thank you for your insight, I'll try to do that... I wished there was an easier way...
thanks again.
Tags
GridView
Asked by
Jonx
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Jonx
Top achievements
Rank 2
Share this question
or