position reset on event drag

Hiya,

I am trying to validate event drag usecase in timeline view. Use case: If the event is dragged to an invalid slot (for example in past) then an error message is shown to the user and event is reset to its original position.

The problem is: if event is dragged to some slot (that is in the past) in a different row then the event’s position is not reset to original but the next available position in that row. If event is dragged to an invalid slot in the same row then everything is working fine and event is reset to its original position.

Here is my code sample handling this stuff:

                scheduler.attachEvent("onBeforeEventChanged", function(event, native_event, is_new){
                    return blocker(event);
                });
            var blocker = function(ev){
                var res;
                if(ev.start_date<new Date()){
                    alert("Cannot move in the back date");
                    res=false;
                }else{
                    alert("Test updated to start at: "+ev.start_date);
                    res=true;
                }
                if (!res) {
                    scheduler._drag_id = null;
                    scheduler._drag_mode = null;
                    scheduler.callEvent("onLimitViolation",[ev.id, ev]);
                }
                return res;
            };

Any pointers/help will be highlt appreciated.

Thanks,
Rehan

Hello,

Your code worked just fine locally. Be sure to update your timeline.js and treetimeline.js file from the Known issues page in our documentation or simply grab them in the attached file.

Best regards,
Ilya
dhtmlxscheduler_timeline.zip (6.22 KB)

Hiya,

It did not work for me, unfortunately. Can you please try running my sample code (very basic timeline example) to see if it works okay on your side. I have attached the code.

After un-archiving, open ‘tester.html’ file in browser and try dragging event ‘GHI’ (in Physics) to one row above (in Math row) and one column left (in week#29). It gives an error as normal but does not reset the event’s position to its original.

I am using the latest build for dhtmlxScheduler and the js files provided by (running on firefox 5.0). If it runs okay on your side then we might are using different version of codebase or browsers.

Thanks very much for you support.
Rehan
Test.rar (271 KB)

Hello,

Thank you for the sample. I was wrong, you need to update dhtmlxscheduler.js file itself. I’ve attached it or you can grab fresh copy from the ‘Scheduler 3.0 Beta’ thread.

Kind regards,
Ilya
dhtmlxscheduler.zip (23 KB)

This one worked! :slight_smile:

Thanks very much,
Rehan