Unplanned
Last Updated: 21 Oct 2022 15:34 by Rick
ITC
Created on: 28 Jul 2022 10:49
Category: Grid
Type: Feature Request
2
Support autogenerated columns for new members that hide members from the base type

Consider the following example. It will trigger AmbiguousMatchException, because reflection discovers two SpecialProp properties.

<TelerikGrid TItem="@GridModel"
             Data="@GridData"
             AutoGenerateColumns="true">
</TelerikGrid>

@code {
    List<GridModel> GridData { get; set; } = new();

    protected override void OnInitialized()
    {
        for (int i = 1; i <= 3; i++)
        {
            GridData.Add(new GridModel()
            {
                SpecialProp = i,
                Text = "Text " + (i * 111)
            });
        }
    }

    public record GridModel : Base1 { }

    public record Base1 : Base2
    {
        public new decimal? SpecialProp { get => base.SpecialProp / base.HelperProp.GetValueOrDefault(1); set => base.SpecialProp = value.HasValue ? (int)(value.GetValueOrDefault() * base.HelperProp.GetValueOrDefault(1)) : null; }
    }

    public record Base2
    {
        public int? SpecialProp { get; set; }
        public string Text { get; set; }
        public int? HelperProp = 10;
    }
}

Why not replace

private PropertyInfo FieldPropertyInfo => ContainerGenericArgument?.GetProperty(Field);

with something like

PropertyInfo FieldPropertyInfo = ContainerGenericArgument?.GetProperties().FirstOrDefault(p => p.Name == Field);

with the possibility to cache the result from GetProperties()?

1 comment
Rick
Posted on: 21 Oct 2022 15:34
I have run into this issue with the TreeView as well.