We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Different work hours for each day.

Thread ID:

Created:

Updated:

Platform:

Replies:

149954 Dec 16,2019 08:33 AM UTC Dec 18,2019 06:22 AM UTC React - EJ 2 3
loading
Tags: Schedule
Sinchan NIkam
Asked On December 16, 2019 08:33 AM UTC

Hi Team,

I need to be set the different work hours for each day.

Following are the day and their work hours and they have stored in State variable name as "workHours" as below.



While set-up work hours with scheduler component with the reference of code in synchfusion.

I'm using "forEach" loop to set workHours.

However in the result, workHours only applied to Sunday, Thursday and Friday...and for the remaining day it applies the default workHours i.e "09:00" to "18:00".

Below is the sample code while set-up work hours in component.

this.scheduleObj.activeView.renderDates.forEach(element => {
    let day = (new Date(element).getDay()) + 1
    this.workHours.forEach(workHour => {
        if (workHour.DayNo === day) {
            //console.log(new Date(element).getDay(),workHour.DayNo,[new Date(element)], workHour.StartTime, workHour.EndTime)
            this.scheduleObj.setWorkHours([new Date(element)],workHour.StartTime, workHour.EndTime)                            
        }
    })
})

Kindly suggest the solution for it.

Regards,
Sinchan.

Vinitha Devi Murugan [Syncfusion]
Replied On December 17, 2019 08:45 AM UTC

Hi Sinchan, 
 
Syncfusion Greetings. 
 
We could reproduce the issue at our end. Before setting custom work hours, we need to reset the work hours as highlighted below to resolve this problem. For your reference we prepared the sample below. 
 

onDataBinding() { 
    if ((this.scheduleObj.activeView.viewClass !== "e-month-view") && (this.scheduleObj.activeView.viewClass !== 'e-agenda-view')) { 
      this.scheduleObj.activeView.renderDates.forEach(element => { 
        let day = (new Date(element).getDay()) + 1 
        this.workHours.forEach(workHour => { 
          if (workHour.DayNo === day) { 
            this.scheduleObj.resetWorkHours([new Date(element)], "00:00", "24:00"); 
            this.scheduleObj.setWorkHours([new Date(element)], workHour.StartTime, workHour.EndTime) 
          } 
        }) 
      }) 
    } 
  } 

 
Kindly try the able sample and let us know if you need further assistance on this. 
                                                                                                           
Regards, 
M.Vinitha devi 


Sinchan NIkam
Replied On December 17, 2019 09:11 AM UTC

It's working.

Many Thanks...

Vinitha Devi Murugan [Syncfusion]
Replied On December 18, 2019 06:22 AM UTC

Hi Sinchan, 
 
Thanks for your update. 
 
You are most welcome 😊 
 
Regards, 
M.Vinitha devi 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon