We have a grid as the snippet below.
I can't figure out how to put a FilterMenu on the Template(d) columns.
The Filter shows up for the "Id" column, which is just a field.
Is it possible to have a filter menu for the columns which are Template?
<TelerikGrid Data="@_vehicleParts"
Pageable="true"
Sortable="true"
FilterMode="Telerik.Blazor.GridFilterMode.FilterMenu"
Resizable="true"
Reorderable="true"
PageSize="20"
Navigable="true"
OnRead=@OnVehiclePartsRead
TotalCount="@TotalCount">
<GridColumns>
<GridColumn Width="10%" Field="Id"/>
<GridColumn Width="10%" Title="Year">
<Template Context="vehiclePartCtx">
@{
if (vehiclePartCtx is VehiclePart { BaseVehicle: { } } vehiclePart)
{
<span>@vehiclePart.BaseVehicle.YearId</span>
}
else
{
<span>???</span>
}
}
</Template>
</GridColumn>
I have a very similar scenario where I'd like to search by a field in a ForeignKey related model.
<GridColumn Title="Client Name" Field="@nameof(WebInvoice.Booking.Client.ClientName)"> <Template> @{ var item = context as WebInvoice; @(item.Booking.Client.ClientName) } </Template> </GridColumn>
The data is available from the database in the query that populates the model (as it shows in the Template) so I would have thought I should be able to search by it as well but instead I get an error:
Changing the top level model to incorporate this related field is of course theoretically possible, but would be a complete pain and wrecks how the EF Core data layer works. Surely this would be a very common requirement? Is there no other workaround?