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:
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.
id:event_id, //scheduler.uid() for new events
Thank-you for your reply.
When I include the event ID, I have the opposite problem… The status is always “updated”, even when I am trying to insert a new event…
This is because the unique ID that the scheduler has assigned the event is being transferred in the addEvent function.
How can I distinguish between the DHTMLX scheduler event ID generated when the event is rendered and my own applications ID’s?
I am having a hard time working out how I can get this to work?
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.