<SfSchedule TValue="AppointmentData" Height="650px" @bind-SelectedDate="@CurrentDate">
<ScheduleEvents TValue="AppointmentData" EventRendered="OnEventRendered"></ScheduleEvents>
<ScheduleViews>
<ScheduleView Option="View.Day"></ScheduleView>
<ScheduleView Option="View.Week"></ScheduleView>
<ScheduleView Option="View.Month"></ScheduleView>
</ScheduleViews>
<ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings>
</SfSchedule>
@code {
DateTime CurrentDate = new DateTime(2020, 1, 31);
public List<string> CustomClass = new List<string>() { "custom-class" };
public void OnEventRendered(EventRenderedArgs<AppointmentData> args)
{
args.CssClasses = CustomClass;
}
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) }
};
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; }
}
}
<style>
.e-schedule .e-vertical-view .e-all-day-appointment-wrapper .e-appointment.custom-class,
.e-schedule .e-vertical-view .e-day-wrapper .e-appointment.custom-class,
.e-schedule .e-month-view .e-appointment.custom-class {
background: #32CD32;
}
</style> |
@code {
DateTime CurrentDate = new DateTime(2020, 1, 31);
List<AppointmentData> DataSource = new List<AppointmentData>
{
new AppointmentData{ Id = 1, Subject = "Meeting - 1", StartTime = new DateTime(2020, 1, 31, 9, 30, 0) , EndTime = new DateTime(2020, 1, 31, 11, 0, 0), CssClass = "e-darkcyan" },
new AppointmentData{ Id = 2, Subject = "Meeting - 2", StartTime = new DateTime(2020, 1, 31, 11, 30, 0) , EndTime = new DateTime(2020, 1, 31, 12, 0, 0), CssClass = "e-black" },
new AppointmentData{ Id = 3, Subject = "Meeting - 3", StartTime = new DateTime(2020, 1, 30, 6, 30, 0) , EndTime = new DateTime(2020, 1, 30, 12, 30, 0), CssClass = "e-aqua" },
new AppointmentData{ Id = 4, Subject = "Meeting - 4", StartTime = new DateTime(2020, 1, 26, 12, 0, 0) , EndTime = new DateTime(2020, 1, 26, 16, 0, 0), CssClass = "e-aquamarine" },
new AppointmentData{ Id = 5, Subject = "Meeting - 5", StartTime = new DateTime(2020, 1, 28, 11, 30, 0) , EndTime = new DateTime(2020, 1, 28, 12, 0, 0), CssClass = "e-blueviolet" },
new AppointmentData{ Id = 6, Subject = "Meeting - 6", StartTime = new DateTime(2020, 1, 28, 6, 0, 0) , EndTime = new DateTime(2020, 1, 28, 12, 0, 0), CssClass = "e-chartreuse" }
};
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 CssClass { get; set; }
}
}
<style>
.e-aliceblue {
background: aliceblue !important;
}
.e-antiquewhite {
background: antiquewhite !important;
}
.e-aqua {
background: aqua !important;
}
.e-aquamarine {
background: aquamarine !important;
}
.e-black {
background: black !important;
}
.e-blue {
background: blue !important;
}
.e-blueviolet {
background: blueviolet !important;
}
.e-brown {
background: brown !important;
}
.e-cadetblue {
background: cadetblue !important;
}
.e-chartreuse {
background: chartreuse !important;
}
.e-darkcyan {
background: darkcyan !important;
}
.e-darkturquoise {
background: darkturquoise !important;
}
</style> |