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

Schedule access resource in renderCell

Thread ID:

Created:

Updated:

Platform:

Replies:

148558 Oct 24,2019 03:35 PM UTC Sep 29,2020 11:42 AM UTC Angular - EJ 2 9
loading
Tags: Schedule
Jan van Rossum
Asked On October 24, 2019 03:35 PM UTC

I'm using the timeline schedule with resources, quite similar to this one:

Is there a way from the renderCell event
to access the corresponding resource (row) of the cell?

Thanks for your reply.

Vinitha Devi Murugan [Syncfusion]
Replied On October 25, 2019 07:03 AM UTC

Hi Jan van, 

Greetings from Syncfusion. 

It is possible to get the corresponding resource details in renderCell event. We have prepared the below sample for the same. 


onRenderCell(args: RenderCellEventArgs): void { 
  if (args.element.classList.contains('e-work-cells')) { 
 // RenderCell event has the groupIndex in it’s parameter which help us to get the resource details  
by calling getResourceByIndex method. 
    let resource: ResourceDetails = this.scheduleObj.getResourcesByIndex(args.groupIndex); 
    console.log(resource); 
  } 
 } 



Regards, 
M.Vinitha devi 



Jan van Rossum
Replied On October 28, 2019 08:48 AM UTC

It's perfect, thank you!

Vinitha Devi Murugan [Syncfusion]
Replied On October 28, 2019 09:37 AM UTC

Hi Jan van, 
 
We are happy to hear that our solution has fulfilled your requirement.  
 
Regards, 
M.Vinitha devi 


Jan van Rossum
Replied On October 28, 2019 09:49 AM UTC

I just noticed that in the mobile/touch view (where there is shown only one resource at a time), args.groupIndex is undefined
You can reproduce this by running the example using the mobile emulator in the Chrome DevTools for instance.
Is there another way to reach the groupIndex and/or the resource from there?


Karthigeyan Krishnamurthi [Syncfusion]
Replied On October 29, 2019 08:32 AM UTC

Hi Jan, 
 
Thanks for the update. 
 
Kindly use the below code example to overcome the reported issue. 
 
onRenderCell(args: RenderCellEventArgs): void { 
    if (args.element.classList.contains("e-work-cells")) { 
      let resource: ResourceDetails = this.scheduleObj.getResourcesByIndex( 
        this.scheduleObj.getCellDetails(args.element).groupIndex 
      ); 
      console.log(resource); 
    } 
  } 
 
Regards, 
Karthi 


Jan van Rossum
Replied On October 29, 2019 09:28 AM UTC

Yes, this works in both cases. 
Thanks for providing the solution!

Karthigeyan Krishnamurthi [Syncfusion]
Replied On October 30, 2019 04:47 AM UTC


Guilbaud William
Replied On September 28, 2020 10:06 AM UTC

Hello,

My goal is to color the background of my cells in different colors regarding to the appointment inside (for example if one day is overbooked I want the background to be red whereas if there is still availability I want it to be green). For this, I want to access ressources in my renderCell function :  

However, I've tried both methods but its always returns me undefined when I try to print it into my console.



My issue is that args.groupIndex is also undefined.

Is there somethings I'm doing wrong? Am I doing it the wrong way?

Thanks for your reply.


Hareesh Balasubramanian [Syncfusion]
Replied On September 29, 2020 11:42 AM UTC

Hi Guilbaud, 

Thanks for the update. 

We have validated your shared query “I've tried both methods but its always returns me undefined when I try to print it into my console” at our end. And we have prepared the sample with your shared snippets and the groupIndex are properly getting at our end. And the sample can be viewed from the following link. 

Code snippet
  onRenderCell(args: RenderCellEventArgs): void { 
    if (args.element.classList.contains("e-work-cells") || args.element.classList.contains("e-work-hours")) { 
      let resourceIndex: number = args.groupIndex; 
      console.log('index : ' + resourceIndex); 
      let resource1: ResourceDetails = this.scheduleObj.getResourcesByIndex(args.groupIndex); 
      console.log("Method 1 : " + resource1); 
      let resource2: ResourceDetails = this.scheduleObj.getResourcesByIndex( 
        this.scheduleObj.getCellDetails(args.element).groupIndex 
      ); 
      console.log("Method 2 : " + resource2); 
    } 
  } 


Kindly try the above sample and if the issue still persists at your end kindly share the below details to serve you better? 
 
  • Replicate the issue in the above sample
  • Share the issue replicating sample (if possible)
 
Regards, 
Hareesh 


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