DataGrid Sub Properties Column Filter in FilterMode CheckBoxList

This new feature was something I was excited about. But I do not seem to get it to work. The Filter doesn't display anything when using a sub property. I also tried it in the demo.

<RadzenDataGrid @ref=grid AllowPaging="true" AllowSorting="true" AllowFiltering="true" **FilterMode="FilterMode.CheckBoxList"** Data="@orders">
    <Columns>
        <RadzenDataGridColumn Property="Customer.CompanyName" Title="Company Name" />
        <RadzenDataGridColumn Property="OrderDetails" FilterProperty="Product.ProductName" Title="Product Name" Type="typeof(IEnumerable<OrderDetail>)" Sortable="false">
            <Template>
                @(string.Join(',', context.OrderDetails.Select(od => od.Product.ProductName)))
            </Template>
        </RadzenDataGridColumn>
    </Columns>
</RadzenDataGrid>

Am I missing something?

This demo is not using CheckBoxList filter, this is the demo you are looking for:

1 Like

Hi, thx for the quick response. I know it is not using the CheckBoxList, but you can alter it and run. I've been using this process several times to test things out.

That is why I posted the altered demo html to simulate. It gives the same results as in my application.

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Specified method is not supported.
System.NotSupportedException: Specified method is not supported.
   at Radzen.Blazor.DynamicLinqCustomTypeProvider.ResolveType(String typeName)

The demo code is not suitable for CheckBoxList type of filtering - setting simply this property will not work. You either need to update the code that applies Contains filter on first render or you need to remove it. For this code to work with CheckBoxList filter you need to update filter operator to In and the value to array of strings not plain string.

Is it possible to let us know what we need to change to the following simple example to get the check box list filtering working?

@using RadzenBlazorDemos.Data
@using RadzenBlazorDemos.Models.Northwind
@using Microsoft.EntityFrameworkCore

@inherits DbContextPage

<RadzenDataGrid @ref=grid AllowPaging="true" AllowSorting="true" AllowFiltering="true" Data="@orders" FilterMode="FilterMode.CheckBoxList">
    <Columns>
        <RadzenDataGridColumn Property="Customer.CompanyName" Title="Company Name" />
    </Columns>
</RadzenDataGrid>

@code {
    RadzenDataGrid<Order> grid;
    IQueryable<Order> orders;

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        orders = dbContext.Orders.Include("OrderDetails.Product").Include("Customer");
    }
}

Here is what I see with your code using our latest version in the demos:

Keep in mind that the generated query might not be able to be translated to SQL by EF and you need to have ToList() to apply the filtering in-memory.

Thank you @enchev. Your suggestion fixed the above example.
However when the sub property is of type Enum it still does not work.

Please take a look at the following example. Filtering via "Color Name" (string) column works ok. Filtering via the column "Color Type" (Enum) is not working.
Is there something I need to change to get it to work?

@using System.ComponentModel.DataAnnotations

<RadzenDataGrid AllowPaging="true" AllowSorting="true" AllowFiltering="true" Data="@employees" FilterMode="FilterMode.CheckBoxList">
    <Columns>
        <RadzenDataGridColumn Property="@nameof(Employee.ID)" Title="ID" />
        <RadzenDataGridColumn Property="@nameof(Employee.Gender)" Title="Gender" />
        <RadzenDataGridColumn Property="@nameof(Employee.Status)" Title="Nullable Status" />
        <RadzenDataGridColumn Property="Color.Name" Title="Color Name" />
        <RadzenDataGridColumn Property="Color.Type" Title="Color Type" />
    </Columns>
</RadzenDataGrid>

@code {
    IEnumerable<Employee> employees;

    public class Employee
    {
        public int ID { get; set; }
        public GenderType Gender { get; set; }
        public StatusType? Status { get; set; }    
        public MyColor Color { get; set; }    
    }

    public class MyColor
    {
        public string Name {get; set;}
        public ColorType Type { get; set; }
    }

    public enum GenderType
    {
        Ms,
        Mr,
        Unknown,
    }

    public enum ColorType
    {
        Red,
        Green,
        Blue,
        [Display(Description = "Almond Green")]
        AlmondGreen,
        [Display(Description = "Amber Gray")]
        AmberGray,
        [Display(Description = "Apple Blue... ")]
        AppleBlueSeaGreen,
        //[Display(Description = "Miss", ResourceType = typeof(ResourceFile)] localization example
        [Display(Description = "Azure")]
        AzureBlue,

    }

    public enum StatusType
    {
        Inactive,
        Active,
    }

    protected override void OnInitialized()
    {
        employees = Enumerable.Range(0, 10).Select(i =>
            new Employee
            {
                ID = i,
                Gender = i < 3 ? GenderType.Mr : i < 6 ? GenderType.Ms : GenderType.Unknown,
                Status = i < 3 ? StatusType.Active : i < 6 ? StatusType.Inactive : null,
                Color = i < 2 
                    ? new MyColor { Name = "Red", Type = ColorType.Red }
                    : i < 4 
                        ? new MyColor { Name = "Almond Green", Type = ColorType.AlmondGreen } 
                        : i < 6 
                            ? new MyColor { Name = "Apple Blue Sea Green", Type = ColorType.AppleBlueSeaGreen }
                            : new MyColor { Name = "Azure Blue", Type = ColorType.AzureBlue },
            });
    }
}

I was able to replicate and fix the problem. The fix will be part of our next update early next week.