Catch event when Expanding/Collapsing Resources in Scheduler.

Hello,
Is there a way to know when the user Expands or Collapses the Resources in the Scheduler?
I want to be able to catch the event so I can update some data.
Thank you.

3 Replies 1 reply marked as answer

RV Ravikumar Venkatesan Syncfusion Team August 27, 2020 01:08 PM UTC

Hi Leonardo, 

Greetings from Syncfusion support. 

We have validated your reported query “Is there a way to know when the user Expands or Collapses the Resources in the Scheduler?” at our end. We have to let you know when we performing the Resource Expand and Collapse operation, the actionBegin event is triggered. So, we can update the data in the actionBegin event of the Scheduler like the below code. We have prepared a sample for your reference and it can be available below. 

[Index.razor] 
@{ 
    if(ExpandCollapse != null) 
    { 
        <em><p>@ExpandCollapse</p></em> 
    } 
} 
 
<SfSchedule TValue="TimelineResourceView" SelectedDate="@CurrentDate" Height="550px"> 
   <ScheduleEvents TValue="TimelineResourceView" OnActionBegin="OnActionBeginEvent"></ScheduleEvents> 
</SfSchedule> 
 
@code{ 
    public DateTime CurrentDate = new DateTime(2020, 8, 26); 
 
    public string ExpandCollapse; 
 
    public async void OnActionBeginEvent(ActionEventArgs<TimelineResourceView> args) 
    { 
        string[] RequestArray = { "resourceCollapse", "resourceExpand" }; 
        if (Array.IndexOf(RequestArray, args.RequestType) > -1) 
        { 
            ExpandCollapse = args.RequestType; 
        } 
    } 
} 


Kindly try the above sample and get back to us if you need any further assistance. 

Regards, 
Ravikumar Venkatesan 


Marked as answer

LL Leonardo Lo Turco Fiao August 27, 2020 01:35 PM UTC

Hi Ravikumar,

Thank you that worked.

I have another question, is there a way to know exactly what resource we're clicking?
The event doesn't seem to have this information.

Thanks


RV Ravikumar Venkatesan Syncfusion Team August 28, 2020 03:20 PM UTC

Hi Leonardo, 
  
Thanks for the update. 
  
We have validated your reported query “Is there a way to know exactly what resource we're clicking?” at our end. We have achieved your requirement with the help of the below-highlighted code. We have prepared a sample for your reference and it can be available below. 
  
[Index.razor] 
@{ 
    if (GroupData != null && GroupData.Any()) 
    { 
        <SfSchedule TValue="TimelineResourceView" @ref="ScheduleRef" SelectedDate="@CurrentDate" Height="550px"> 
            <ScheduleEvents TValue="TimelineResourceView" OnActionBegin="OnActionBeginEvent"></ScheduleEvents> 
        </SfSchedule> 
    } 
} 
@code{ 
        SfSchedule<TimelineResourceView> ScheduleRef; 
  
        public DateTime CurrentDate = new DateTime(2020, 8, 26); 
  
        public string ExpandCollapse; 
  
        public async void OnActionBeginEvent(ActionEventArgs<TimelineResourceView> args) 
        { 
            string[] RequestArray = { "resourceCollapse", "resourceExpand" }; 
            if (Array.IndexOf(RequestArray, args.RequestType) > -1) 
            { 
                // You can get the expanded resource details here 
                var resourceDetails = await ScheduleRef.GetResourcesByIndex(args.GroupIndex); 
                var clickedResourceDetail = resourceDetails.ResourceData; 
                ExpandCollapse = args.RequestType; 
            } 
        } 
} 
  
  
Kindly try the above sample and get back to us if you need any further assistance. 
  
Regards, 
Ravikumar Venkatesan 


Loader.
Up arrow icon