Checkbox filter vs collection properties

Hi there!
I like new checkbox filter, but i dunno how to use it for collection properties...
I've got column with task performers (sometimes more than one for each task), and i use template to show them as one string:

<RadzenDataGridColumn TItem="Task" Property="Performers" Title="Task performers" Width="auto"
                   FilterProperty="Performers">
     <Template Context="data">
         <RadzenLabel Text="@(string.Join(", ", data.Performers.Select(p => p.Employee?.DisplayString)))" ></RadzenLabel>
     </Template>                          
 </RadzenDataGridColumn>

But I have no idea how to set my property collection data to checkbox filter. FilterProperty="Performesr.Employee.DisplayString" aslo not work.
Is there any way to do it with default markup? Or only way is to use custom filter template?

Thanks in advance!

Not supported out-of-the-box, only with custom template.

Sad, but ok, thanks anyway!

There are plenty of examples in our demos on how to create custom FilterTemplate with CheckBoxList:


1 Like

Here is something that will work out-of-the-box in our next update before the end of the week:

@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" />
        <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>

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

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

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

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            var column = grid.ColumnsCollection.Where(c => c.Property == "OrderDetails").FirstOrDefault();

            if (column != null)
            {
                column.SetFilterValue(new string[] { "Tofu" });
                column.SetFilterOperator(FilterOperator.In);
                await grid.Reload();
            }
        }

        await base.OnAfterRenderAsync(firstRender);
    }
}

1 Like