Dataprocess nativeeditor_status almost always "inserted"

Hello,

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:

scheduler.addEvent({
        start_date: bStartDate,
        end_date: bEndDate,
        text: bName,
        notes: bNotes
    });

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?

Thanks,
Tim

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 });

Hi Stanislav,

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?

Thanks,

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.