DHTMLX / scheduler

GPL version of JavaScript Event Scheduler
https://dhtmlx.com/docs/products/dhtmlxScheduler/
GNU General Public License v2.0
315 stars 111 forks source link

Final question on recurring events #39

Closed AllanCodes closed 6 years ago

AllanCodes commented 6 years ago

How can I pragmatically, in JavaScript, delete a recurring event. I have the id, however since it attaches id#morenumbers, for each recurring event I'm not sure how I'd go about deleting all instances of a recurring event. Can you please point me out to the respective docs, the only one I found was for server side and I cannot follow that.

Thanks!

AlexKlimenkov commented 6 years ago

Hi, in order to delete all instances of a recurring events you simply need to delete a parent record. Occurrences are created on the client and their ids a generated as 'id#timestamp', so you can get a series id from it:

var seriesId = (id + "").split("#")[0];
scheduler.deleteEvent(seriesId);

or you can read event_pid value from the occurrence object

var occurrence = scheduler.getEvent(occurrenceId);//occurrenceId -> 'id#timestamp'
var seriesId = occurrence.event_pid;
if(seriesId){
   scheduler.deleteEvent(seriesId);
}