Calendar.. how to clear all events?

Hi, i want to clear all events from calendar, but when i call to method “calendar.getEventProvider().getEvents().clear()” from code, all events are still showing. how can i clear the view?. regards!!.

Hi,

Could you clarify what approach do you use to add events to the calendar? Do you use a datasource or EventProvider?

hi, i use event provider, the list goes empty when the “clear” method of the provider is called. anyway, the calendar still showing the events; either if i change the date range from code and back to previous range, event still there. i set the eventprovider at the “init” method of the screen, then i use that instance everywhere with getEventProvider().

Currently, to remove all event you need to remove each one separately, for instance:

public void removeAllEvents() {
    CalendarEventProvider eventProvider = calendar.getEventProvider();
    // Used to prevent ConcurrentModificationException
    List<CalendarEvent> events = new ArrayList<>(eventProvider.getEvents());
    for (CalendarEvent event : events) {
        eventProvider.removeEvent(event);
    }
}

I’ve created a YouTrack issue PL-10674.

Regards,
Gleb

1 Like