DHTMLX scheduler does not load the current recurring event data in light box

I am using “dhtmlx-scheduler”: “^6.0.2” in my angular 14 application. I am using postgres DB to store the events and the frontend uses a java api for the CRUD operations. This is my code to update the recurring event.

  1. What happens here is I am receiving same startdate and enddate in the console.error(‘update event’, data) print statement. whereas my event is originally scheduled with NO END DATE. It is supposed to be like thi s"9999-02-01 05:00:00.000000 +00:00".

  2. Also the light box is not loaded with correct data. My event is scheduled for everyday but in the lightbox (wg=hile trying to edit), “monthly” is selected as default.

    scheduler.attachEvent(‘onEventChanged’, async (id: string | number, data: any) => {
    console.error(‘update event’, data)
    //all modified occurrences must be deleted when you update a recurring series
    if (data.rec_type && data.rec_type != “none”) {
    this.http.deleteModifiedOccurrences(data.id).then(resp => {
    console.log(“Delete all modified occurrences”)
    });
    }
    const updateData: any = {
    id: data.id,
    startDate: moment.utc(moment(data.start_date)).format(‘YYYY-MM-DDTHH:mm:ss[Z]’),
    endDate: moment.utc(moment(data.end_date)).format(‘YYYY-MM-DDTHH:mm:ss[Z]’),
    text: data.text,
    name: data.name,
    login: this.loginId,
    eventPid: data.event_pid || 0,
    eventLength: data.event_length || 0,
    recType: data.rec_pattern || ‘’,
    eventColor: data.priority == ‘1’ ? ‘#EE8E97’ : (data.priority == ‘2’ ? ‘#92E0A3’ : ‘#E0AE8F’),
    }
    await this.http.updateEvent(updateData);
    window.location.reload();
    }, null);

Hello @rajeswarij ,

Regarding this part:

What happens here is I am receiving same startdate and enddate in the console.error(‘update event’, data) print statement. whereas my event is originally scheduled with NO END DATE. It is supposed to be like thi s"9999-02-01 05:00:00.000000 +00:00".

It’s hard to suggest what exactly goes wrong without seeing your code, data examples and information on what you are exactly editing - occurrence or full recurring series, but the event will always have end/start dates, even if series has No end date, each occurrence will have its own dates:
Main recurring series data:

Single occurrence data:

If it doesn’t work in your case, possible you are sending some incorrect data to the server side, so you can check the request to the server, but it’s hard to suggest what goes wrong without data examples, and server request/response. Or a simplified demo with all necessary files and instructions, that I will be able to run locally and reproduce the issue.

Regarding this part:

Also the light box is not loaded with correct data. My event is scheduled for everyday but in the lightbox (wg=hile trying to edit), “monthly” is selected as default.

It also could happen if the series/occurrence data is incorrect, but it’s hard to suggest what exactly goes wrong in your case without data examples.

Regarding this part:

scheduler.attachEvent(‘onEventChanged’, async (id: string | number, data: any) => {
console.error(‘update event’, data)
//all modified occurrences must be deleted when you update a recurring series
if (data.rec_type && data.rec_type != “none”) {
this.http.deleteModifiedOccurrences(data.id).then(resp => {
console.log(“Delete all modified occurrences”)
});
}
const updateData: any = {
id: data.id,
startDate: moment.utc(moment(data.start_date)).format(‘YYYY-MM-DDTHH:mm:ss[Z]’),
endDate: moment.utc(moment(data.end_date)).format(‘YYYY-MM-DDTHH:mm:ss[Z]’),
text: data.text,
name: data.name,
login: this.loginId,
eventPid: data.event_pid || 0,
eventLength: data.event_length || 0,
recType: data.rec_pattern || ‘’,
eventColor: data.priority == ‘1’ ? ‘#EE8E97’ : (data.priority == ‘2’ ? ‘#92E0A3’ : ‘#E0AE8F’),
}
await this.http.updateEvent(updateData);
window.location.reload();
}, null);

The code looks mostly correct, as I don’t know what exactly goes on your updateEvent method. There is important moment - if you are changing the single occurrence, you should change the series data(update the main series) and after that create the new event(with the addEvent, that will be connected with the parent series by the event_pid property.

You can check the following instruction on changing occurrences, just to be sure that you are using the required update logic:
https://docs.dhtmlx.com/scheduler/recurring_events.html#editingdeletingacertainoccurrenceintheseries