Scheduler event update issue using dataprocessor

Hi,

We are currently facing an issue, that after using scheduler for some time, few events after modifying it don’t allow to get updated any more and when we try to update it (by modifying info or moving event), it shows event in bold and keeps it in bold. If we delete it, it shows it as strike out, but does not delete it. Rest of the events work normally (i.e. CRUD works on other events that have not resulted in this type of anomaly). We tried to reproduce this using same parameters, sometimes it gets reproduced and sometimes it does not :frowning: .
For now to make that event to work normally again, we have to do browser refresh to refresh the page and scheduler. After that event that resulted in this anomaly works fine again. However this type of anomaly shows up again after some time.

We have been trying to debug this issue for sometime now, so decided to post this in the forum, so someone can point us to the right direction. People in this forum have been extremely helpful in the past as well :slight_smile:

From implementation point of view, we have customized the scheduler to use

  • nodejs is used for synchronization of scheduler for clients (Don’t know if its because of this)

  • We mainly use firefox for testing.

  • Custom before insert and before update java functions

    Java Code
    =======================================
    @Override
    public void beforeInsert(DataAction action) {
    // Inputs: action.get_value…
    // our implementation here…
    // Outputs: action.set_response_attributes …
    action.success(newRecordID);
    }

    @Override
    public void beforeUpdate(DataAction action) {
    // Inputs: action.get_value…
    // our implementation here…
    // Outputs: action.set_response_attributes …
    action.success();
    }
    =======================================
    Java Script Code
    =======================================
    myDP = new dataProcessor("/eventsx.do");
    myDP.setTransactionMode(“POST”, true);
    myDP.live_updates(“http://”+ location.hostname +":8008/sync");

    myDP.defineAction(“error”, function(response) {
    var message = response.getAttribute(“message”);
    alert("Error: " + message);
    return false;
    });
    myDP.defineAction(“invalid”, function(response) {
    var message = response.getAttribute(“message”);
    alert("Invalid: " + message);
    return false;
    });

    myDP.defineAction(“inserted”, function(node) {
    try {
    // Set values using this type of call:
    // scheduler.getEvent(node.attributes.getNamedItem(“sid”).nodeValue).text
    // = node.attributes.getNamedItem(“text”).nodeValue;
    // scheduler.updateEvent()…
    return true;
    }
    catch (e) {
    console.error('ERROR IN myDP.defineAction(“inserted”): ’ + e
    }
    return false;

    });

    myDP.defineAction(“updated”, function(node) {
    try {
    // Set values using this type of call:
    // scheduler.getEvent(node.attributes.getNamedItem(“sid”).nodeValue).text
    // = node.attributes.getNamedItem(“text”).nodeValue;
    // scheduler.updateEvent()…
    return true;
    }
    catch (e) {
    console.error('ERROR IN myDP.defineAction(“updated”): ’ + e
    }
    return false;
    });

    myDP.init(scheduler);
    =======================================

Thanks in advance.

SimSim

Hi,
make sure the server-response after update/insert/delete request is sent in correct format and has Content-Type:text/xml or application/xml
docs.dhtmlx.com/doku.php?id=dhtm … e#response

The described issue may happen when client-side fails to process the dataprocessor response

Thanks for following up on this. We are currently not setting “content-type”. Maybe that could be the reason. I will try it out. Thanks.

Seems like content-type is automatically being set:
see attached image.

This is the sample xml response:

<?xml version='1.0' encoding='utf-8' ?>

The above response looks valid
In case of FF and Chrome it may be important that <?xml version='1.0' encoding='utf-8' ?> is placed as first line of output. If you have newline or some white spaces before <?xml tag, client side can have problems with xml parsing.

Also, the problem can occurs if you have some js error in methods assigned through defineAction, but they look too simple to have any errors :slight_smile:

Are you using the latest scheduler or some 2.x version ?

Currently we are using: dhtmlxScheduler v.3.7 build 130220.

Furthermore I will verify the recommendations you suggested.

Thanks :slight_smile:

You can try to update scheduler to 4.0
It is backward compatible, so you can use the existing code without any modifications.

just updated to 4.0.1 and testing the app. Will update if anything comes up.

Thanks :slight_smile:

We discovered that during re-load of the scheduler the data processor has a list of invalid and in progress events. We noticed that the in progress list had events with a ‘wait’ status. The invalid list had events with databases ID and also others that had the time value in milliseconds. If any of these events are modified after the data re-load, the data processor fails to save them and shows the text in bold.

We have found a couple of posts on the forum with similar issues and it was suggested that they needed to clear the data processor’s in progress list and call the sendData method using the code below:
// based on viewtopic.php?f=6&t=33219&start=0
dp._in_progress = {};
dp.sendData();

Another post suggested clearing the data processor updated rows list and invalid list
// based on viewtopic.php?f=2&t=13478
dp.updatedRows = [];
dp._invalid = {};

Does dataprocessor._invalid list has any affect on whether an event gets saved or not? Is dataprocessor._in_progress used to save events or style them in bold font? Is it safe to call all four lines in succession after reloading the data? or do we need a special handler to call sendData asynchronously? Please advise.

dataprocessor._invalid
Yes. Invalid items will not be saved automatically. Any edit of such item will clear invalid flag though. So if you have item in invalid list, it will be saved after any UPDATE operation ( edit, drag, etc. )

dataprocessor._in_progress
Items in this list will not be saved. Normally this list must be empty. If you have some records here it means that

  • you are reloading the scheduler while it in data saving process ( data sent to server but response not retrieved yet )
  • server side code sends invalid response, and client side doesn’t detect that item was saved

Thanks for your reply.

It seems that the issue is related to how the data processor is re-initialized upon reloading of the scheduler. My application has a refresh button which allows the user to re-load the datebook. The code looks like this:

//…
// on application start-up. This is done only once:
dp = new dataProcessor("/myapp/scheduler/eventsx.do");
//…

// on refresh button press
//…
dp._in_progress = {};
dp.sendData();

dp.updatedRows = [];
dp._invalid = {};

scheduler.clearAll();
scheduler.load("/myapp/scheduler/eventsdata.do?uid=" + scheduler.uid() + “&usrid=” + app.userID.dataValue);
//…

Is this a valid and safe way to refresh the scheduler? Do we need to invoke anything else on the data processor object before or after clearing the scheduler? Can the dp.sendData() be done in asynchronous mode or do we need to wait for it to complete before we invoke scheduler.clearAll()?

You can try to use it like next

dp.sendData(); dp._in_progress = {}; dp.updatedRows = []; ...reload...

It is still a hack, but must not cause any side effects.

Fully legal solution would be to use onFullSync event of dataprocessor and reload scheduler after it. ( onFullSync occurs after data sending call, response from server side received, so all data is saved and you can safely reload without resetting any inner collections of dataprocessor )