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

Delete calendar items

I have a calendar with events and I would like to remove all items to repopulate with new data. How can I do it?


1 Reply

SS SaiGanesh Sakthivel Syncfusion Team April 6, 2023 09:12 AM UTC

Hi Juan,


#Regarding delete all the appointments and add new appointment in the SfCalendar

We suggest that you remove all appointment from the view model collection after removing it from the Firebase database and add the new item to the view model collection along with the FireBase Database. This way, the change will be reflected in the view immediately. Please refer to the following code snippet for your reference.


Code snippet

private async void allDelete_Clicked(object sender, EventArgs e)

{

    foreach (var appointment in viewmodel.Appointments)

    {

        await firebaseHelper.DeleteEvent(appointment.Subject);

    }

 

    viewmodel.Appointments.Clear();

 

    DateTime today = DateTime.Now.Date;

    var newAppointment = new CalendarInlineEvent() { StartTime = today.AddHours(16), EndTime = today.AddHours(17), Subject = "new item" };

    viewmodel.Appointments.Add(newAppointment);

    await firebaseHelper.AddEvents(newAppointment.StartTime, newAppointment.EndTime, newAppointment.Subject);

}


Please refer to the demo sample in the attachment. Please let us know if you have any concerns.


Regards,
SaiGanesh Sakthivel


Attachment: CalendarXamarin_7872ae79.zip

Loader.
Live Chat Icon For mobile
Up arrow icon