I have a custom editor sidebar for editing new and existing events. When I drag a new event in the scheduler the dates and name are loaded into the sidebar. I have a save button which activates the following:
When I submit the values the dataprocessor always submits with “inserted”, which means I can’t distinguish between a newly created event or an existing event.
I have tried adding the following before and after the scheduler.addEvent call:
dp.setUpdated(bookingId);
If I edit an event by dragging or moving the correct status of “updated” is sent.
How can I distinguish wether an event that has been loaded into the sidebar already exists in the database?
When code calls addEvent method it is clear signal that new event was added. If you want to update existing event you need to be sure that addEvent contains the id of event. In such case if event with such id exists - it will be updated instead of inserting.
scheduler.addEvent({
id:event_id, //scheduler.uid() for new events
start_date: bStartDate,
end_date: bEndDate,
text: bName,
notes: bNotes
});
The scheduler will generate “update” action if event with such ID already exists. It still must generate “insert” action if you are using ID but such ID was not used by any other event.
Events IDs generated by scheduler is timestamp based, you can check (id > 949352400000) but it rather ugly solution. When you are working with scheduler’s lightbox you can use scheduler.getState() to get info about currently edited event, not sure can it be used with your custom solution or not.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan