Scheduler addEvent not firing DP onBeforeDataSending


#1

I’m having some trouble with the DataProcessor occasionally not recognizing events that have been added to a dhtmlx schedule via addEvent. The problem only happens about 5% of the time, but when it does occur, it frequently happens with several transactions in a row. I believe it’s more likely to occur in sites with a slower Internet connection.

The problem occurs within a JavaScript function that swaps work shift events between two employees. The function uses deleteEvent to remove the original scheduler event, which updates the server data reliably. The subsequent addEvent method displays the new event correctly on the client browser, but occasionally does not trigger an insert on the server.

The code is shown below. I’ve been able to verify that the “onBeforeDataSending” event does not fire when the problem occurs. The getState method also returns “undefined” when executed immediately after the addEvent for transactions that have the problem.

                // DELETE old shift
                scheduler.deleteEvent(eventObj.id);

                // INSERT new shift
                var newEventObj = {
                    store: eventObj.store,
                    start_date: eventObj.start_date,
                    end_date: eventObj.end_date,
                    text: eventObj.text,
                    startBreak: eventObj.startBreak,
                    weekEnd: eventObj.weekEnd,
                    employeeID: newEmployeeID,
                    sectionID: newEmployeeID,
                    schedule: eventObj.schedule,
                    timeType: eventObj.timeType,
                    userID: "Swap:" + winId
                };
                var eventId = scheduler.addEvent(newEventObj);
                scheduler.getEvent(eventId).eventKey = eventId; // save original eventId as eventKey
                var syncState = schedulerDP.getState(eventId);
                message("Swap INSERT:" + eventId + ", state = " + syncState, "LOG");    // syncState is sometimes undefined?
    schedulerDP.attachEvent("onBeforeDataSending", function (id, state, data) {
        message("onBeforeDataSending: ID" + dpId + ", state=" + state, "LOG"); // "DEBUG"

A typical transaction generates debug messages showing “state=inserted” followed by a onBeforeDataSending message:

A failed transaction generates debug message “state=undefined” without a onBeforeDataSending message:


#2

I’ve been looking for a bug like yours, addEvent did not do the insert while it was painted on screen.

I’ve looked in source and came up with this solution: (adopted to your code)
// at seperate line because ‘!’ is illegal in object naming, but “named arrays” do have the same storage methods as object properties:
new_object["!nativeeditor_status"] = “inserted”;

There is definitely a bug somewhere, when I disable the lightbox coming on screen bij doing “return false;” in “onBeforeLightbox”, not one addEvent comes through as “inserted”. They all come into phpserver as “updated” which does perform a SQL-language perfect UPDATE but as the ID does not exist, UPDATE returns with “0 lines updates” and data is lost…


#3

Hello, Syprer

Your problem was described and solved in the support ticket. If it wasn’t your ticket, please, provide some details of your custom code for the event inserting.