Diiferent workhours weekend
Hi
Is it possible to have different workhours for weekends.
For example:
Monday-Friday 8:00-18:00
Saturday 9:00-16:00
Sunday 10:00 - 14:00
Regards,
/Stefan
SIGN IN To post a reply.
1 Reply
SK
Satheesh Kumar Balasubramanian
Syncfusion Team
September 16, 2021 07:30 AM UTC
Hi Stefan,
Thanks for using Syncfusion Products.
We have validated your reported query "Is it possible to have different workhours for weekends" and prepared sample to achieve your requirement using SetWorkHours and ResetWorkHours method in DataBound event of the scheduler which can be downloaded from the following link.
Index.razor:
|
bool isLayoutRendered = false;
public void OnDataBound() { if (!isLayoutRendered) { List<DateTime> dates = ScheduleRef.GetCurrentViewDates(); //get current view dates ScheduleRef.ResetWorkHours(dates, null, null); //reset existing work hours List<DateTime> workDates = new List<DateTime>(); foreach (ResourceData doctor in WorkHourData) { foreach (DateTime date in dates) { foreach (int day in doctor.WorkDays) { if ((int)date.DayOfWeek == day) { workDates.Add(date); //add the work days for specific resource } } } ScheduleRef.SetWorkHours(workDates, doctor.StartHour, doctor.EndHour); //set work hours for specific days and hours workDates = new List<DateTime>(); } isLayoutRendered = true; } } public void OnNavigated() { isLayoutRendered = false; //to set work hours on view/date change } public List<ResourceData> WorkHourData { get; set; } = new List<ResourceData> { new ResourceData{ Id = 1, WorkDays = new int[] { 1, 2, 3, 4, 5 }, StartHour = "08:00", EndHour = "18:00" }, new ResourceData{ Id = 2, WorkDays = new int[] { 0 }, StartHour = "09:00", EndHour = "16:00" }, new ResourceData{ Id = 3, WorkDays = new int[] { 6 }, StartHour = "10:00", EndHour = "14:00" } }; |
Kindly try the above sample and let us know if this meets your requirement.
Regards,
Satheesh Kumar B
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
ST Stefan
- Sep 15, 2021 08:58 AM UTC
- Sep 16, 2021 07:30 AM UTC