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. Image for the cookie policy date

Change Event Color According To The Time Interval

Hi,

I want to change the color of the event according to the time interval. If the event is back than now, it should be red. If it's going to start at a later time, it should be green, If it is currently in progress, it should be blue. How can I do this ? Please find attached a sample image.

Attachment: schedule_cec8344c.rar

3 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team August 8, 2019 03:45 AM

Hi Mehmet, 
 
Syncfusion greetings. 
 
We can achieve your requirement using eventRendered event and kindly refer the below sample. 
 
eventRendered(args: EventRenderedArgs): void { 
    let data: { [key: string]: Object } = args.data; 
    if ((data.StartTime as Date).getTime() < new Date().getTime() && (data.EndTime as Date).getTime() < new Date().getTime()) { 
      args.element.style.backgroundColor = 'red'; 
    } 
    else if (((data.StartTime as Date).getTime() < new Date().getTime() && (data.EndTime as Date).getTime() > new Date().getTime())) { 
      args.element.style.backgroundColor = 'blue'; 
    } 
    else if ((data.StartTime as Date).getTime() > new Date().getTime() && (data.EndTime as Date).getTime() > new Date().getTime()) { 
      args.element.style.backgroundColor = 'green'; 
    } 
  } 
 
 
 
 
Regards, 
Karthi 



MY mehmet yanbak August 9, 2019 06:59 AM

Hi,

It works, thank you so much :)


KK Karthigeyan Krishnamurthi Syncfusion Team August 12, 2019 01:18 AM

Most welcome 😊


Loader.
Live Chat Icon For mobile
Up arrow icon