Add loading states to MudDataGrid components
Implemented loading indicators and progress colors for all MudDataGrid instances across Events, Students, Teams, and Registration components to enhance user experience during data loading operations.
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
</MudStack>
|
||||
</MudText>
|
||||
|
||||
<MudDataGrid T="StudentTeamInfo" ServerData="ServerReload" @ref="_dataGrid" @key="_gridKey" Filterable="true" RowsPerPage="35" Dense="true" Striped="true" Hover="true">
|
||||
<MudDataGrid T="StudentTeamInfo" ServerData="ServerReload" @ref="_dataGrid" @key="_gridKey" Filterable="true" RowsPerPage="35" Dense="true" Striped="true" Hover="true" Loading="@_isLoading" LoadingProgressColor="Color.Primary">
|
||||
<Columns>
|
||||
<PropertyColumn Property="@(e => e.Student.LastName)" Title="Student" Sortable="true">
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
|
||||
@code {
|
||||
MudDataGrid<StudentTeamInfo> _dataGrid = null!;
|
||||
private bool _isLoading = true;
|
||||
private bool _showRegionalOnly;
|
||||
private bool _showGrade;
|
||||
private bool _showRegionalId;
|
||||
@@ -167,35 +168,43 @@
|
||||
|
||||
private async Task<GridData<StudentTeamInfo>> ServerReload(GridState<StudentTeamInfo> state)
|
||||
{
|
||||
// Load all students with their teams
|
||||
var students = await Context.Students
|
||||
.Include(s => s.Teams)
|
||||
.ThenInclude(t => t.Event)
|
||||
.Include(s => s.Teams)
|
||||
.ThenInclude(t => t.Captain)
|
||||
.ToListAsync();
|
||||
|
||||
// Filter to only students with teams
|
||||
var studentTeams = students
|
||||
.Where(s => s.Teams.Any(t => t?.Event != null && (!_showRegionalOnly || t.Event.RegionalEvent)))
|
||||
.Select(s => new StudentTeamInfo
|
||||
{
|
||||
Student = s,
|
||||
Teams = s.Teams?.Where(t => t?.Event != null).ToList() ?? []
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// Apply sorting
|
||||
var sortedData = ApplySorting(studentTeams, state.SortDefinitions);
|
||||
|
||||
var totalItems = sortedData.Count();
|
||||
var pagedData = sortedData.Skip(state.Page * state.PageSize).Take(state.PageSize).ToArray();
|
||||
|
||||
return new GridData<StudentTeamInfo>
|
||||
_isLoading = true;
|
||||
try
|
||||
{
|
||||
TotalItems = totalItems,
|
||||
Items = pagedData
|
||||
};
|
||||
// Load all students with their teams
|
||||
var students = await Context.Students
|
||||
.Include(s => s.Teams)
|
||||
.ThenInclude(t => t.Event)
|
||||
.Include(s => s.Teams)
|
||||
.ThenInclude(t => t.Captain)
|
||||
.ToListAsync();
|
||||
|
||||
// Filter to only students with teams
|
||||
var studentTeams = students
|
||||
.Where(s => s.Teams.Any(t => t?.Event != null && (!_showRegionalOnly || t.Event.RegionalEvent)))
|
||||
.Select(s => new StudentTeamInfo
|
||||
{
|
||||
Student = s,
|
||||
Teams = s.Teams?.Where(t => t?.Event != null).ToList() ?? []
|
||||
})
|
||||
.ToList();
|
||||
|
||||
// Apply sorting
|
||||
var sortedData = ApplySorting(studentTeams, state.SortDefinitions);
|
||||
|
||||
var totalItems = sortedData.Count();
|
||||
var pagedData = sortedData.Skip(state.Page * state.PageSize).Take(state.PageSize).ToArray();
|
||||
|
||||
return new GridData<StudentTeamInfo>
|
||||
{
|
||||
TotalItems = totalItems,
|
||||
Items = pagedData
|
||||
};
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user