Selection of multiple events by code

How is it possible to select multiple events programmatically?

If the user selects one event I want to delete all other events, which can have different relations to this event and which are not recurring events or something else. So my idea was to select all required events by code and delete them together.
Or is there a way to flag them as "deleted" without triggering everytime the "eventRemoved" (OnActionCompleted Event) per deleted scheduler event.

5 Replies 1 reply marked as answer

NR Nevitha Ravi Syncfusion Team July 15, 2020 11:34 AM UTC

Dear Customer, 

Greetings from Syncfusion Support. 

We have prepared a sample for your requirement “delete relating events when user deletes an event” using DeleteEvent public method. In the following sample when user deleting an event, we have deleted the appointments named ‘Conference’ for your reference. 

public async void OnActionComplete(ActionEventArgs<AppointmentData> args) 
    
        if (args.RequestType == "eventRemoved") 
       
            List<AppointmentData> data = DataSource.FindAll(x => x.Subject.Contains("Conference")); 
            if (data.Count > 0) 
           
                await ScheduleRef.DeleteEvent(data); 
           
       
   

Please try the solution and get back to us if you need any further assistance. 

Regards, 
Nevitha 



ZD ZMI Dev July 17, 2020 05:42 AM UTC

Thanks for your answer,
In the meantime I found another solution for this. Maybe it helps someone else:

I added the appointment in the OnActionBegin Event to the DeletedRecords collection, this prevents the multiple call of OnActionComplete where I have other functionalities which should not be triggered.
It seems to work. Please tell me if this is not the best practice or can create some problems.

public async Task OnSchedulerActionBegin(ActionEventArgs<EmployeeChronoTypificationAppointment> args)
{
    if (args.RequestType == "eventRemove")
    {
        var removeEvent = args.DeletedRecords.FirstOrDefault();
        var removableAppointments = (await Scheduler.GetEvents()).Where(e => e.Employee.Id == removeEvent.Employee.Id && e.Id != removeEvent.Id);
 
        foreach (var appointment in removableAppointments)
        {
           args.DeletedRecords.Add(appointment);
        }
    }
}

And please tell me, is there a way to select programmatically some appointments?


HB Hareesh Balasubramanian Syncfusion Team July 20, 2020 12:18 PM UTC

Dear Customer, 

Thanks for the update. 

Q1: In the meantime I found another solution for this. Maybe it helps someone else: 
 
We are happy that, you have found an alternate solution at your end. 
 
Q2: And please tell me, is there a way to select programmatically some appointments? 
 
This query can be achieved by adding a CSS “e-appointment-border” class to the appointment  element structure. And for the same we have prepared the below sample, to select the events programmatically. And the sample can be downloaded from the following link. 
 
Code snippet: 
    public string[] selectedClass = { "e-appointment-border" }; 
    public void EventRendered(EventRenderedArgs<AppointmentData> args) 
    { 
        args.Element.AddClass(selectedClass); 
    } 


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

Regards, 
Hareesh 


Marked as answer

ZD ZMI Dev July 23, 2020 08:54 AM UTC

Q2: 

Sorry, but I don't get the point, where do you select the related appointments here? And how do I get all selected appointments in a later event?

It should happen the same like I do with Ctrl+Mouseclick on different Events. Now I have multiple Events selected and for example with DEL I delete all of it.

I want the following functionality: I have multiple appointments and now the user selects one of these by clicking on it, it should automatically select all related appointments. And than I can work with all selected apointments.




HB Hareesh Balasubramanian Syncfusion Team July 24, 2020 04:01 PM UTC

Dear Customer, 

Thanks for the update. 

We have validated your shared query at our end and for that, we have considered this as a feature request and logged the task. We will implement and rolled out this feature in our upcoming Volume 2 SP release. You can track the further feature details through below link. 
 
 
Regards, 
Hareesh 


Loader.
Up arrow icon