Hi, I had a deselect issue before and you fixed it in this topic link but now I'm facing other issues. I added a checkbox column to my grid because I want to let users to select all without selecting one by one but in this situation:
1- When I change page, selections are staying but checkboxes are being empty.
2- When I select all, other selections that I did from other pages are disappearing.
Am I doing something wrong or is this another bug?
Here is my example code
@using RadzenBlazorDemos.Data
@using RadzenBlazorDemos.Models.Northwind
<RadzenDataGrid @ref="grid" @bind-Value=@selectedEmployees SelectionMode="DataGridSelectionMode.Multiple" KeyProperty="EmployeeID" IsLoading="@isLoading" Count="@count" Data="@employees" LoadData="@LoadData" FilterPopupRenderMode="PopupRenderMode.OnDemand" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterMode="FilterMode.Advanced" AllowSorting="true" AllowFiltering="true" AllowPaging="true" PageSize="4" PagerHorizontalAlign="HorizontalAlign.Center" TItem="Employee" ColumnWidth="200px">
<Columns>
<RadzenDataGridColumn TItem="Employee" Width="60px" Sortable="false" Filterable="false">
<HeaderTemplate>
<RadzenCheckBox TriState="false" TValue="bool?" InputAttributes="@(new Dictionary<string,object>(){ { "aria-label", "Select all items" }})"
Value="@(selectedEmployees == null || selectedEmployees?.Any() != true ? false : !employees.All(i => selectedEmployees.Contains(i)) ? null : employees.Any(i => selectedEmployees.Contains(i)))"
Change="@(args => selectedEmployees = args == true ? employees.ToList() : null)" />
</HeaderTemplate>
<Template Context="data">
<RadzenCheckBox TriState="false" Value="@(selectedEmployees != null && selectedEmployees.Contains(data))" InputAttributes="@(new Dictionary<string,object>(){ { "aria-label", "Select item" }})"
TValue="bool" />
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="Employee" Property="EmployeeID" Filterable="false" Title="ID" Frozen="true" Width="50px" TextAlign="TextAlign.Center" />
<RadzenDataGridColumn TItem="Employee" Property="LastName" Title="Last Name" Width="150px"/>
<RadzenDataGridColumn TItem="Employee" Property="TitleOfCourtesy" Title="Title Of Courtesy" />
<RadzenDataGridColumn TItem="Employee" Property="BirthDate" Title="Birth Date" FormatString="{0:d}" />
<RadzenDataGridColumn TItem="Employee" Property="HireDate" Title="Hire Date" FormatString="{0:d}" />
<RadzenDataGridColumn TItem="Employee" Property="Address" Title="Address" />
<RadzenDataGridColumn TItem="Employee" Property="City" Title="City" />
</Columns>
<LoadingTemplate>
<RadzenProgressBarCircular ProgressBarStyle="ProgressBarStyle.Primary" Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate" />
</LoadingTemplate>
</RadzenDataGrid>
@code {
bool isLoading;
int count;
ODataEnumerable<Employee> employees;
IList<Employee> selectedEmployees;
RadzenDataGrid<Employee> grid;
NorthwindODataService service = new NorthwindODataService("https://services.radzen.com/odata/Northwind/");
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}
async Task LoadData(LoadDataArgs args)
{
isLoading = true;
var result = await service.GetEmployees(filter: args.Filter, top: args.Top, skip: args.Skip, orderby: args.OrderBy, count: true, expand: "NorthwindOrders($expand=Customer)");
// Update the Data property
employees = result.Value.AsODataEnumerable();
// Update the count
count = result.Count;
isLoading = false;
}
}