How can I cancel a operation?

Hi, Team

I drag the event after I release the mouse I need to detect the collision events, if I found collision events I’ll rollback the operation and all changes, but I didn’t know how to cancel a operation in currently codes.

Have anyone can help me on this? Thanks.

Best wishes,

Judo

I just used below method to implement my requirement:

scheduler.attachEvent(“onBeforeEventChanged”,function(start, end){
collisionEndDate = end;
collisionStartDate = start;
})

And call it in mouse_up function:
scheduler._on_mouse_up=function(e){
if (this._drag_mode && this._drag_id){
this._els[“dhx_cal_data”][0].style.cursor=“default”;
//drop
var ev=this.getEvent(this._drag_id);
if (!this._drag_event.start_date || ev.start_date.valueOf()!=this._drag_event.start_date.valueOf() || ev.end_date.valueOf()!=this._drag_event.end_date.valueOf()){
this.callEvent(“onBeforeEventChanged”,[this._drag_event.start_date, this._drag_event.end_date]);

Then make the collision detect and rollback my operation and changes:
this.attachEvent(“onEventChanged”,function(id){
if (getCollision(id)){
scheduler.getEvent(id).start_date=collisionStartDate;
scheduler.getEvent(id).end_date=collisionEndDate;
}
if (!this._loading && this.validId(id)){
dp.setUpdated(id,true,“updated”);
}
});

But I didn’t thinks this was a high efficient way to implement this, so have any other idea on this?

Best wishes,

Judo

Check support.dhtmlx.com/x-files/sched … lision.zip

This is experimental extension which do the same - prevent dnd operation if they are introducing a collision.

Thanks very much, I just try it and it works well.