The CheckBoxList Filter isn't updating the selectable values after changing the data in the DataGrid. I have a DropDown that when the value is changed, loads data used by a Data Grid with FilterMode.CheckBoxList like the example below.
Select an order ID from the dropdown
Click the Order Filter, note the value available
Select a different order ID from the dropdown
Click the Order Filter, note the value available hasn't changed.
If you clear, next time you open it will be updated. Sometimes opening/closing other filters updates it.
It happens when columns' AllowCheckBoxListVirtualization is true or false.
I used DataGridMasterDetail.razor as the base to make this example:
@using RadzenBlazorDemos.Data
@using RadzenBlazorDemos.Models.Northwind
@using Microsoft.EntityFrameworkCore
@inherits DbContextPage
@if (orders == null)
{
<p><em>Loading...</em></p>
}
else
{
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-sm-12">
<RadzenLabel Text="Select Value" Component="DropDownBindValue" ValueChanged="OnSelectedJudgeChanged" />
<RadzenDropDown TValue="Order" Data=@AllOrders Style="width: 100%; max-width: 400px;" Name="DropDownBindValue" ValueChanged="OnSelectedItemChanged"
TextProperty="OrderID">
</RadzenDropDown>
</RadzenStack>
<RadzenDataGrid
Data="@(SelectedOrders)"
FilterMode="FilterMode.CheckBoxList"
AllowColumnReorder="true"
AllowCompositeDataCells="true"
AllowGrouping="true"
AllowColumnPicking="true"
AllowPickAllColumns="true"
ColumnsPickerAllowFiltering="true"
AllowSorting="true"
AllowMultiColumnSorting=true
ShowMultiColumnSortingIndex="true"
AllowFiltering="true"
FilterCaseSensitivity=FilterCaseSensitivity.CaseInsensitive
FilterDelay="10">
<Columns>
<RadzenDataGridColumn Property="Order.CustomerID" Title="Order" AllowCheckBoxListVirtualization="false"/>
<RadzenDataGridColumn Property="Product.ProductName" Title="Product" />
<RadzenDataGridColumn Property="UnitPrice" Title="Unit Price">
<Template Context="detail">
@String.Format(new System.Globalization.CultureInfo("en-US"), "{0:C}", detail.UnitPrice)
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn Property="@nameof(OrderDetail.Quantity)" Title="Quantity" />
<RadzenDataGridColumn Property="@nameof(OrderDetail.Discount)" Title="Discount">
<Template Context="detail">
@String.Format("{0}%", detail.Discount * 100)
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
}
@code {
IList<Order> AllOrders ;
IList<OrderDetail> SelectedOrders { get; set; }
IQueryable<Order> orders;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
orders = dbContext.Orders
.Include("Customer")
.Include("Employee")
.Include("OrderDetails")
.Include("OrderDetails.Product");
AllOrders = orders.ToList();
// SelectedOrders = new List<Order>(){ orders.FirstOrDefault() };
}
private async Task OnSelectedItemChanged(Order order)
{
await Task.Delay(10);
SelectedOrders = order.OrderDetails.ToList();
}
}