@using Syncfusion.Blazor.Schedule
<SfSchedule TValue="AppointmentSortData" Width="100%" EnableAutoRowHeight="true" @bind-SelectedDate="@CurrentDate" @bind-CurrentView="@SelectedView">
<ScheduleEventSettings SortBy="RankId" DataSource="@DataSource"></ScheduleEventSettings>
<ScheduleViews>
<ScheduleView Option="View.Day"></ScheduleView>
<ScheduleView Option="View.Week"></ScheduleView>
<ScheduleView Option="View.WorkWeek"></ScheduleView>
<ScheduleView Option="View.Month"></ScheduleView>
<ScheduleView Option="View.TimelineDay"></ScheduleView>
<ScheduleView Option="View.TimelineWeek"></ScheduleView>
<ScheduleView Option="View.TimelineWorkWeek"></ScheduleView>
<ScheduleView Option="View.TimelineMonth"></ScheduleView>
</ScheduleViews>
</SfSchedule>
@code{
DateTime CurrentDate = new DateTime(2020, 2, 14);
View SelectedView = View.Week;
DataSource = new List<AppointmentSortData>
{
new AppointmentSortData { Id = 1, Subject = "Rank A", RankId="A", StartTime = new DateTime(2020, 2, 13, 10, 0, 0) , EndTime = new DateTime(2020, 2, 13, 12, 0, 0) },
new AppointmentSortData { Id = 2, Subject = "Rank B", RankId="B", StartTime = new DateTime(2020, 2, 13, 7, 0, 0) , EndTime = new DateTime(2020, 2, 13, 15, 0, 0) },
new AppointmentSortData { Id = 3, Subject = "Rank C", RankId="C", StartTime = new DateTime(2020, 2, 13, 9, 0, 0) , EndTime = new DateTime(2020, 2, 13, 10, 30, 0) },
new AppointmentSortData { Id = 4, Subject = "Rank D", RankId="D", StartTime = new DateTime(2020, 2, 13, 9, 30, 0) , EndTime = new DateTime(2020, 2, 13, 14, 0, 0) }
};
public class AppointmentSortData
{
public int Id { get; set; }
public string Subject { get; set; }
public string Location { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
public Nullable<int> RecurrenceID { get; set; }
public string RankId { get; set; }
}
}This code, lets call it code A, is directly copied from https://blazor.syncfusion.com/documentation/scheduler/appointments. It has the SortBy field. This code for some reason does not work, so I changed to use code B, which is an example exactly on top of code A in the documentation page. I twisted code B by adding the SortBy function:
@using Syncfusion.Blazor.Schedule
<SfSchedule TValue="AppointmentData" Height="550px" @bind-SelectedDate="@CurrentDate">
<ScheduleEventSettings SortBy="Priority" DataSource="@DataSource">
</ScheduleEventSettings>
<ScheduleViews>
<ScheduleView Option="View.Day"></ScheduleView>
<ScheduleView Option="View.Week"></ScheduleView>
<ScheduleView Option="View.WorkWeek"></ScheduleView>
<ScheduleView Option="View.Month"></ScheduleView>
<ScheduleView Option="View.Agenda"></ScheduleView>
</ScheduleViews>
</SfSchedule>
@code{
DateTime CurrentDate = new DateTime(2020, 1, 31);
List<AppointmentData> DataSource = new List<AppointmentData>
{
new AppointmentData { Id = 1, Subject = "Meeting", StartTime = new DateTime(2020, 1, 31, 9, 30, 0) , EndTime = new DateTime(2020, 1, 31, 11, 0, 0),
Status = "Completed", Priority = "High"}
};
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public string Location { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
public Nullable<int> RecurrenceID { get; set; }
public string Status { get; set; }
public string Priority { get; set; }
}
}Strangely, I got an error complaining that SortBy does not exist. Is there any correct way to do SortBy?
Thanks a lot for the prompt reply, I found out that I was using a wrong Blazor version. After using the latest Syncfusion Blazor, the problem disappeared.