Hello.
I'm creating a lot of grid for an admin system i'm doing. But i'm having issue with nested filtering.
It works fine for 1 lvl when setting the property like this: Car.Registration
However, if i need to go one level futher, it doesn't work anymore. Like this: Car.ApiCar.Brand
As you can see on the image the filter is just an empty string. There is however a FilterDescriptor
Can anyone help me out here?
enchev
June 14, 2023, 7:31am
2
I'm unable to reproduce such problem:
@using System.Linq.Dynamic.Core
<RadzenDataGrid AllowSorting="true" AllowFiltering="true" AllowPaging="true" Data="@orders" Count="@count" TItem="Order" LoadData="@LoadData">
<Columns>
<RadzenDataGridColumn TItem="Order" Property="OrderId" Title="OrderId" />
<RadzenDataGridColumn TItem="Order" Property="OrderDetail.OrderDetailId" Title="OrderDetailId" />
<RadzenDataGridColumn TItem="Order" Property="OrderDetail.Product.ProductId" Title="ProductId" />
</Columns>
</RadzenDataGrid>
@code {
IEnumerable<Order> data = Enumerable.Range(0, 100).Select(i =>
new Order()
{
OrderId = i,
OrderDetail = new OrderDetail()
{
OrderDetailId = i * 2,
Product = new Product()
{
ProductId = i * 4
}
}
});
int count;
IEnumerable<Order> orders;
void LoadData(LoadDataArgs args)
{
var query = data.AsQueryable();
if (!string.IsNullOrEmpty(args.Filter))
{
query = query.Where(args.Filter);
}
if (!string.IsNullOrEmpty(args.OrderBy))
{
query = query.OrderBy(args.OrderBy);
}
count = query.Count();
orders = query.Skip(args.Skip.Value).Take(args.Top.Value).ToList();
}
public class Order
{
public int OrderId { get; set; }
public OrderDetail OrderDetail { get; set; }
}
public class OrderDetail
{
public int OrderDetailId { get; set; }
public Product Product { get; set; }
}
public class Product
{
public int ProductId { get; set; }
}
}
Thank you for the reply.
It's weird. It works fine for our Company.User.Name
But not Car.ApiCar.Brand
But as you can see from the image in the first page there is actually a FilterDescriptor in the list, it should have build a filter from ?
Can you explain to me how it works when it builds filters ?
enchev
June 14, 2023, 1:11pm
4
You can check the source code for reference.
wojt
June 14, 2023, 2:06pm
5
Are you expanding the query to include Car.ApiCar?
Yes
query = query.Skip(request.Args.Skip.Value).Take(request.Args.Top.Value)
.Include(v => v.Company)
.ThenInclude(v => v.User)
.Include(v => v.Car)
.ThenInclude(v => v.ApiCar);
I've found the issue.
return GetPropertyType(GetPropertyTypeIncludeInterface(type, part), property.Replace($"{part}.", ""));
When my Car.ApiCar.Brand is run through this, it's suddenly ApiBrand, because both instances of "Car." gets replaced
enchev
June 16, 2023, 9:57am
8
Feel free to submit pull request if you believe you’ve found a bug.
enchev
June 16, 2023, 12:17pm
10
I’ve merged your change - it will be part of our next update early next week.