How to get resource on cell click

Hi, I have been using syncfusion scheduler control in my blazor application.

I have added the resources which are shown on the right side, when you click on cell, I am showing a custom pop-up to add an event.

I want to get the resource when a user clicks on a cell, I did some research on it and found that GetResourcesByIndex method can be used to get the resources.

but this method is throwing an exception, and another method GetResourceByIndex doesn't give any results.

this is how I am using it

var resource = sfSchedule.GetResourcesByIndex(cellClickEventArgs.GroupIndex);

Please advise how can I do that in my application it is very important


1 Reply

SK Satheesh Kumar Balasubramanian Syncfusion Team August 26, 2021 04:32 PM UTC

Hi Jameel, 
  
Thanks for using Syncfusion Products. 
  
We have validated your reported query "How to get resource on cell click" and prepared sample to get resource details on cell click. Please find the sample in the following link. 
  
  
Index.razor:    
<SfSchedule @ref="ScheduleObj" TValue="AppointmentData" Width="100%" Height="650px" @bind-SelectedDate="@CurrentDate" CurrentView="View.TimelineWeek"> 
    ........................................... 
    <ScheduleEvents TValue="AppointmentData" OnCellClick="OnCellClick"></ScheduleEvents> 
</SfSchedule> 
  
@code { 
    public void OnCellClick(CellClickEventArgs args) 
    { 
        var resourceDetails = ScheduleObj.GetResourceByIndex(args.GroupIndex); 
        Random rnd = new Random(); 
        AppointmentData eventData = new AppointmentData { Id = rnd.Next(1000), StartTime = args.StartTime, EndTime = args.EndTime, IsAllDay = args.IsAllDay, ProjectId = resourceDetails.GroupData.ProjectId, TaskId = resourceDetails.GroupData.TaskId }; 
        await ScheduleObj.OpenEditorAsync(eventData, CurrentAction.Add); 
    } 
} 

 
  
Kindly try the above sample and let us know if this works at your end. If you still face any problem, please share the below details to reproduce the issue which will help us to validate the issue and provide prompt solution as soon as possible. 
  • Replicate the issue in above sample or share issue replicating sample if possible
  • Share all schedule related code snippets

Regards, 
Satheesh Kumar B 


Loader.
Up arrow icon