Hi everyone
Need advice
Have a list of items
public class Schedule:BaseFields
{
public string UserID { get; set; }
public string ShiftID { get; set; }
public string SubDepartmentID { get; set; }
public DateTime Date { get; set; }
public TimeOnly Start { get; set; }
public TimeOnly End { get; set; }
public bool IsActive { get; set; }
public int Changes { get; set; }
public UserInformation ShiftUser { get; set; }
public WorkShift Shift { get; set; }
public SubDepartment SubDepartment { get; set; }
}
Where userinformation, shift, subdepartment is a navigation properties ef core
I need build datagrid with dynamic columns (dates of month) and one static(first) column with name of user
Have a problem with building datagrid because not in every day user have an active schedule and monthes have ta diff count of days
So i cant build a grid classic way by static columns count and names of column
In the past i do this table in desktop winforms by row and column indexes/names with loop
For now i do this
List of schedules grouped by user id
<Columns>
<RadzenDataGridColumn TItem="List<Schedule>" Width="160px" Title="username" Frozen=true Filterable=true>
<Template Context="group">
@group.First().ShiftUser.FullName
</Template>
</RadzenDataGridColumn>
@foreach (var date in datesOfMonth)
{
<RadzenDataGridColumn TextAlign="TextAlign.Center" TItem="List<Schedule>" Width="40px" Title="@date.ToString("dd.MM")">
<Template Context="group">
@foreach (var schedule in group)
{
if (schedule.Date == date)
{
<RadzenBadge Style="@($"background-color:{schedule.Shift.Color};color: {schedule.Shift.TextColor};")">
@schedule.Shift.Name
</RadzenBadge>
}
}
</Template>
</RadzenDataGridColumn>
}
</Columns>
But this example not filtering(any type of filter)
And i think in future ill have a problems with cell selection and getting schedule from a cell
Any ideas
Thx for any help
Respect