Posted 14 January 2020, 4:10 am EST - Updated 29 September 2022, 12:50 am EST
Hi colleagues.
Finally, I have found the reason for the problem with binding in FlexGrid.
It appears not only with indexed properties, it appears with binding interfaces
For example. Try to use next hierarchy (2 interfaces and 2 classes). Property “Name” is defined in the root(!!!) of the hierarchy”:
public interface IFirst { public string Name { get; set; } }
public interface ISecond : IFirst { public int Amount { get; set; } }
public class BaseClass : ISecond { public string Name { get; set; } public int Amount { get; set; } }
public class DerClass : BaseClass { }
And then, try to bind tree collections to the FrexGrid:
List data1; //Binding is broken for property “Name”
List data2; //Ok.
List data3; //Ok.
The reason is…
Inside class “C1.Blazor.Core.ExpressionEx”, inside function “GetPropertyPathExpression” you can find call of standard function “Expression.Property(expression1, propertyName)”.
If you decompile it, you can find that it uses function “expression.Type.GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags. Public | BindingFlags.FlattenHierarchy);”
This function works fine with classes but works “bad” with interfaces. In other words, it can find property “Name” inside “BaseClass”, “DerClass” and “IFirst”, but cannot find this property in “ISecond” and throws exception.
Could you fix this limitation?
PS. sorry I cannot make ticket. It has not “Blazor” in combo
FlexGrid-DynamicColumnBinding2.zip