Delete all Events within Daterange

hi there…

is it possible to delete all Events for a given date range, without iterating through scheduler.getEvents() ?

Hello,
Please, see example:
docs.dhtmlx.com/scheduler/snippet/02f69d5f

yes… this will work… thank you!

Hey @Polina,

The snippet seems to be missing (to delete events in a date range). Do you have it available somewhere else? Was hoping to see if it would work for my use case.

Thanks,
Mark

Hello @markatfin,

You can delete events for a date range in two steps:

  1. Get events in a date range with the getEvents method:
    getEvents Scheduler Docs
  2. Loop through events that you got, and run the deleteEvent(id) :
    deleteEvent Scheduler Docs

method for each of them, like follows:

function deleteEvs(){
    var evs = scheduler.getEvents(new Date(2024, 5, 24),new Date(2024, 5, 30)); 
    for (var i=0; i<evs.length; i++){
        scheduler.deleteEvent(evs[i].id)
    }
}

Here is a demo(click the delete events button):
https://snippet.dhtmlx.com/t0vtukep

Kind regards,