Likely related to https://feedback.telerik.com/blazor/1432615-support-for-nested-complex-models
Issue - Filtering / Sorting on a column that is bound to a complex object fails to generate the proper OData string.
Example Grid Code, three columns, column 1 and 3 are bound to a complex class, column 2 just a string:
<TelerikGrid Data=@sysVars.Dtos Pageable="true" Sortable="true" FilterMode="Telerik.Blazor.GridFilterMode.FilterRow" PageSize="20" TotalCount=@sysVars.Count OnRead=@ReadItems>
<GridColumns>
<GridColumn Field=@nameof(SysVar.SysVarType.Name) Title="Type" Editable="false">
<Template>
@{
var data = context as SysVar;
@data.SysVarType.Name
}
</Template>
</GridColumn>
<GridColumn Field=@nameof(SysVar.Value) Title="Value">
<Template>
@{
var data = context as SysVar;
var link = SysVarDto.FrontEndEditUrl(data.Id.Value);
<NavLink href=@link>@data.Value</NavLink>
}
</Template>
</GridColumn>
<GridColumn Field=@nameof(SysVar.Hierarchy.Description) Title="Hierarchy">
<Template>
@{
var data = context as SysVar;
@data.Hierarchy.Description
}
</Template>
</GridColumn>
</GridColumns>
</TelerikGrid>
The values bound to the grid are made up of a complex object. For the sake of the example
public class SysVar
{
public string Value { get; set; }
public Hierarchy Hierarchy { get; set; }
public SysVarType SysVarType { get; set; }
}
public class Hierarchy
{
public string Description { get; set; }
}
public class SysVarType
{
public string Name { get; set; }
}
Right now I know I can't have the Grid render SysVarType.Name, so I use a custom cell and everything works. However, if I try to sort/filter on my complex columns, SysVarType or Hierarchy the resulting OData string that is generated is incorrect.
Example of what is should look like, from a Telerik Grid in my React application if I sort on the sysVarType column:
https://localhost:44335/odata/v1/SysVarOData?$count=true&$expand=sysVarType($select=name),hierarchy($select=description)&$skip=0&$top=20&$orderby=value,sysVarType/name
Same string generated by the Telerik Grid in Blazor
Note: I can't sort two columns at the same time, not a huge issue at this time.
What is failing is the $orderby= doesn't return sysVarType/name and only returns name, causing a 400 on my backend as the class SysVar doesn't have a name field.