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

[Solved] LookupValueConverter on GridViewComboBoxColumn bound to indexed property not working

3 Answers 199 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.
Dan Kane
Top achievements
Rank 1
Dan Kane asked on 08 Sep 2010, 05:55 AM
Hi,
I have a GridViewComboBoxColumn which is bound to an indexed property like so:
<br>column.DataMemberBinding = new Binding("[prop" + item.ItemId + "]");


This works fine except that I would like to use a Converter for the display value, so I have set the LookupValueConverter property on the column like this:

column.LookupValueConverter = new ResponseToStringConverter()
{
    Column = lookupColumn,
    ShowFullDescription = ShowingResponseDescriptions
};

When this runs the values are not converted appropriately using the converter, instead it just uses the DisplayMemberPath property to determine the value to display. This behaviour is only when I am using the indexed property; if I use a normal property name for the binding it does use the converter as I expect.

Am I going about things the wrong way, or is this a bug?

Cheers

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 10 Sep 2010, 10:05 AM
Hi Dan Kane,

I would not recommend to deal with the LookupValueConverer as we are planning to mark it as Obsolete and remove it later .  We have already moved most of the logic it used to handle and using it  would be unreliable.

I will be glad to help solving your problem in alternative way ( w/o the converter) . Can you please paste me some code with the implementation of your business objects and a few lines describing the expected behavior.

Having this will try to provide a working sample app  for you .

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
0
Dan Kane
Top achievements
Rank 1
answered on 14 Sep 2010, 01:51 AM
Thanks for you reply.

Basically I have the GridViewComboBoxColumn bound to a list of objects with a code and description and want to display the code and description together in the column. I have temporarily solved this by putting another property on the lookup object called FullDescription and set the DisplayMemberPath property to this. This works fine, but I would rather be able to implement it just using some display logic if at all possible, rather than having to have this extra property.

I had done this previously just using a LookupValueConverter to return the code (which is the value passed in), plus the description.

This is a very cut down version of what I am trying to achieve:
public class LookupObject
{
    public string Code { get; set; }
    public string Description { get; set; }
    public string FullDescription { get { return Code + " - " + Description; } }
}
 
public void AddColumn()
{
    var Lookups = new List<LookupObject>()
    {
        { new LookupObject() { Code = "1", Description = "One" } },
        { new LookupObject() { Code = "2", Description = "Two" } },
        { new LookupObject() { Code = "3", Description = "Three" } },
    };
 
    var column = new GridViewComboBoxColumn();
    column.DataMemberBinding = new Binding("[prop1]");
    column.ItemsSource = Lookups;
    column.DisplayMemberPath = (ShowingFullDescriptions) ? "FullDescription" : "Description";
    
    //var converter = column.LookupValueConverter as ResponseToStringConverter;
    //if (converter != null) {
    //    converter.ShowFullDescription = ShowingResponseDescriptions;
    //}
}


Also, this is more of a separate issue, but I can't group/filter the columns which are bound to indexed properties either - is this by design? I found this help page which seemed to suggest that it is the binding.


Cheers


 
0
Accepted
Pavel Pavlov
Telerik team
answered on 16 Sep 2010, 02:16 PM
Hi Dan Kane,

If I understand correctly , you need to display two properties - merged in the column.

I believe there is a pure UI solution to this -  using the ItemTemplate property , you can tell the column to display more than one propertry merged.

Please go to
http://demos.telerik.com/silverlight/#GridView/ComboBoxColumn

and click the MultiColumn ComboBox column to see this in action /there is a source code available  as well/.
Greetings,
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
Dan Kane
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Dan Kane
Top achievements
Rank 1
Share this question
or