DataMemberBinding with Converter only works on top level

0 Answers 42 Views
TreeListView
Manuel
Top achievements
Rank 1
Manuel asked on 09 Dec 2025, 08:29 AM

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

Stenly
Telerik team
commented on 11 Dec 2025, 11:07 AM

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?

Manuel
Top achievements
Rank 1
commented on 12 Dec 2025, 07:20 AM

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

Stenly
Telerik team
commented on 12 Dec 2025, 10:43 AM

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.

Manuel
Top achievements
Rank 1
commented on 07 Jan 2026, 11:45 AM

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; }
    }
I have attached the edited sample project.

Thank you and best regards
Manuel
Stenly
Telerik team
commented on 12 Jan 2026, 08:41 AM

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?

Manuel
Top achievements
Rank 1
commented on 19 Jan 2026, 11:06 AM

Hi Stenly,

works like a charm, thank you for your support!

 

Best regards,

Manuel

Stenly
Telerik team
commented on 19 Jan 2026, 11:26 AM

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.

No answers yet. Maybe you can help?

Tags
TreeListView
Asked by
Manuel
Top achievements
Rank 1
Share this question
or