Hi,
I have more or less the same issue as in my other question.
I have the column defined like so:
<telerik:GridViewDataColumn
Header="Business Unit"
UniqueName="BusinessUnit"
DataMemberBinding="{Binding BusinessUnit, Converter={StaticResource BusinessUnitToStringConverter}}"
TextAlignment="Center"
Width="60"
CellStyleSelector="{StaticResource BusinessUnitCellStyleSelector}"
IsVisible="False"
IsFilterable="True"
IsReadOnly="True" />
For the top level, everything works as expected.
In the levels below, it seems like the converter isn't run:
The BusinessUnitToStringConverter should grab the description "PI" instead of the actual value of the enum "MuP".
I am on the latest version (2025.4.1111)
Is there a workaround, or will this be fixed in the next version?
Thanks and best regards,
Manuel
Hello Manuel,
I tested this in a sample application, however, I was unable to reproduce the reported behavior. On my end, all of the rows retrieve the Description attribute's value.
I attached the test project, so, would it be possible to give it a try and let me know how it goes?
Hi Stenly,
thank you for your response, I can confirm it works as expected in your example.
I will check again and try to reproduce it in the sample project.
Thank you and best regards
Manuel
Hello Manuel,
Please take as much time as needed. If you are able to reproduce it, I will be glad to debug this scenario on my end.
Hi Stenly,
I have reproduced the problem in the sample project.
It starts happening when there are different classes inheriting from a common base class within the tree:
public class ItemBase { public string Name { get; set; } public MyEnum MyEnum { get; set; } } public class Item1 : ItemBase { public ObservableCollection<Item2> Children { get; set; } } public class Item2 : ItemBase { public ObservableCollection<Item3> Children { get; set; } } public class Item3 : ItemBase { public ObservableCollection<Item3> Children { get; set; } }Thank you and best regards
Manuel
Hello Manuel,
The observed behavior is expected, as the RadTreeListView supports only homogeneous data (values of the same type). In the provided setup, different types are used, even if they derive from the same object.
With this in mind, even with this setup, the desired behavior can be achieved with a bit of custom code.
More specifically, by extending the GridViewDataColumn and overriding the GetCellContent method, which will allow you to customize the cell's content.
The following code snippets showcase this suggestion's implementation:
public class CustomDataColumn : GridViewDataColumn { protected override object GetCellContent(object item) { object cellValue = base.GetCellContent(item); if (!item.GetType().IsAssignableFrom(base.ItemType) || !this.ItemType.IsAssignableFrom(item.GetType())) { PropertyInfo propertyInfo = item.GetType().GetProperty(this.DataMemberBinding.Path.Path); if (propertyInfo != null) { var propertyValue = propertyInfo.GetValue(item); var convertedValue = this.DataMemberBinding.Converter.Convert(propertyValue, null, null, CultureInfo.CurrentCulture); return convertedValue; } } return cellValue; } }<telerik:RadTreeListView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/> <!--<telerik:GridViewDataColumn DataMemberBinding="{Binding MyEnum, Converter={StaticResource EnumDescriptionConverter}}" CellStyleSelector="{StaticResource BusinessUnitCellStyleSelector}"/>--> <local:CustomDataColumn DataMemberBinding="{Binding MyEnum, Converter={StaticResource EnumDescriptionConverter}}" CellStyleSelector="{StaticResource BusinessUnitCellStyleSelector}"/> </telerik:RadTreeListView.Columns>With this being said, could you give this suggestion a try?
Hi Stenly,
works like a charm, thank you for your support!
Best regards,
Manuel
Hello Manuel,
I am happy to hear that the proposed suggestion resolved the unwanted behavior on your end and that you took the time to let me know.