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

3 posts, 1 answers
  1. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 28 Jun 2010 Link to this post

    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. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 01 Jul 2010 Link to this post

    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
  3. DevCraft banner
  4. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 01 Jul 2010 Link to this post

    ok, thank you for your insight, I'll try to do that... I wished there was an easier way...
    thanks again.
Back to Top