I am working with server side paging and filtering for a mudblazor datagrid, and upon checking a row, everything saves properly, but I cannot get the rows to recheck on page change, with the RowClassFunc.
I tried creating a RowClassFunc applying the class "selected" according to others who have had success, but it is not working.
<MudDataGrid T="ObservationListModel" MultiSelection="@true" @ref="_dataGrid" @bind-SelectedItems="selectedItems" ServerData="LoadGridData" SortMode="SortMode.Multiple" Filterable="true" RowClassFunc="SelectedRowClassFunc" Hideable="false" Elevation="5" Dense="@true"><ToolBarContent><MudSpacer /><MudTextField T="string" Value="@_requestDto.Search" Placeholder="Search" Adornment="Adornment.Start" Immediate="false" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0" ValueChanged="OnSearchChange"></MudTextField></ToolBarContent><Columns><SelectColumn T="ObservationListModel" /><TemplateColumn Sortable="@false" Filterable="@false" Title="Detail" ><CellTemplate><MudStack Row><MudButton Size="@Size.Small" Variant="@Variant.Filled" Href="@($"obsdetail/{context.Item.ReferenceID}/{context.Item.OriginalDataID}")" Color="@Color.Primary">View</MudButton></MudStack></CellTemplate></TemplateColumn><PropertyColumn Property="x => x.ScientificName" Title="Scientific Name" Sortable="true" /><PropertyColumn Property="x => x.ObservationDate" Title="Observation Date" Sortable="true" Filterable="false" /><PropertyColumn Property="x => x.Class" Title="Class" Sortable="true"/><PropertyColumn Property="x => x.CountyName" Title="County" Sortable="true" /><PropertyColumn Property="x => x.Observer" Title="Observer" Sortable="true" /><PropertyColumn Property="x => x.ReviewStatus" Title="Review Status" Sortable="true" /></Columns><PagerContent><MudText>@($"{selectedItems.Count} items selected")</MudText><MudDataGridPager T="ObservationListModel"/></PagerContent></MudDataGrid>@code { private MudDataGrid<ObservationListModel>? _dataGrid; private ObsRequestModel _requestDto = new(); private HashSet<ObservationListModel> selectedItems { get; set; } = new HashSet<ObservationListModel>(); private async Task Search() { if (_dataGrid is not null) { await _dataGrid!.ReloadServerData(); } } private async Task OnSearchChange(string newValue) { _requestDto.Search = newValue; await Search(); } private async Task<GridData<ObservationListModel>> LoadGridData(GridState<ObservationListModel> state) { _requestDto.Filters.Clear(); _requestDto.Page = state.Page + 1; _requestDto.PageSize = state.PageSize; // Extract sorting information var sorting = state.SortDefinitions.FirstOrDefault(); // Assuming single column sorting if (sorting != null) { _requestDto.SortColumn = sorting.SortBy; _requestDto.SortDirection = sorting.Descending == false ? "asc" : "desc"; // Convert Enum to string or appropriate format } // Extract filtering information foreach (var filter in state.FilterDefinitions) { if (filter.Value != null) { var colString = filter.Title.ToString(); var valString = colString == "County" ? await ReferenceService.GetCountyFips(filter.Value.ToString()) : filter.Value.ToString(); _requestDto.Filters.Add(new FilterDefinition { Column = colString, Operator = filter.Operator.ToString(), Value = valString }); } else if (filter.Operator.ToLower() == "is empty" || filter.Operator.ToLower() == "is not empty") { _requestDto.Filters.Add(new FilterDefinition { Column = filter.Title.ToString(), Operator = filter.Operator.ToString(), Value = "0", // Assuming the value is a string, adjust as necessary }); } } ObListDTO Response = await ReferenceService.GetAllObs(_requestDto); GridData<ObservationListModel> data = new() { Items = Response.Items, TotalItems = Response.ItemTotalCount }; return data; } private async Task OnStartDateChanged(DateTime? newDate) { _requestDto.StartDate = newDate; await DateChange(); } private async Task OnEndDateChanged(DateTime? newDate) { _requestDto.EndDate = newDate; await DateChange(); } private async Task DateChange() { if (_dataGrid is not null) { await _dataGrid!.ReloadServerData(); } } public void Dispose() { } private string SelectedRowClassFunc(ObservationListModel element, int rowNumber) { return selectedItems.Contains(element) ? "selected" : string.Empty; }