Hello
I have lookup in combo box column in grid
The problem is the filter display the value of the lookup
I need to display the Name property in the look up and select the value property
Unfortunately I can't Attached picture look at the telerik demos
Grid view -> columns->combo box column->classic binding to object
Best regards
Ehud
3 Answers, 1 is accepted
0
Hi Ehud Pinchas,
Maya
the Telerik team
That would be the expected behavior since the grid filters according to properties in its own data source. You may take a look at this blog post for a reference on how to overcome this.
Maya
the Telerik team
0
Andrey
Top achievements
Rank 1
answered on 25 Mar 2011, 10:32 AM
Somehow this isn't good solution-because you have to spend much time doing good filter control. I've found workaround that fits my case:
i.e. i'm using converter-it works fine in filtering control. but the problem is that you can't bind converter or it's parameter. So another workaround:
Maybe this will help you))
<telerik:GridViewComboBoxColumn Header="Тип" DataMemberBinding="{Binding Path=KindID, Converter={StaticResource kindConverter}}" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=DataContext.DefectKinds}" DisplayMemberPath="Name" SelectedValueMemberPath="Name" />public class KindToNameConverter : IValueConverter { private readonly Dictionary<Int32?, String> _kinds=new Dictionary<Int32?, String>(); private DbInline _context; public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if(value==null||!(value is Int32)) return null; var id = value as Int32?; if (!_kinds.ContainsKey(id)) { if (_context == null) _context = DatabaseRepository.GetDBInlineContext(); var kind = (from kinds in _context.Kinds where kinds.ID == id select kinds).FirstOrDefault(); _kinds.Add(id, kind.Name); } return _kinds[id]; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var name = value as String; if (name == null) return null; foreach (var keyValuePair in _kinds) if (keyValuePair.Value == name) return keyValuePair.Key; if (_context == null) _context = DatabaseRepository.GetDBInlineContext(); var kind = (from kinds in _context.Kinds where kinds.Name == name select kinds).FirstOrDefault(); if (kind != null) { _kinds.Add(kind.ID, kind.Name); return kind.ID; } return null; } }0
Andrey
Top achievements
Rank 1
answered on 25 Mar 2011, 10:47 AM
I think there could be general solution. If you try co inherit from comboboxcolumn and put some general converter between DatamemberBinding and DisplayValue on the fly. But I currently have no time to try something like this.