Hello, I want to get the names of section (from) and section (to) while drop event to new section (I want to create prompt - "Are you sure to move this event from {section_name_from} to } {section_name_to} How to achive that?
Hello @pawelktr ,
You can do it with the onBeforeEventChanged
event:
https://docs.dhtmlx.com/scheduler/api__scheduler_onbeforeeventchanged_event.html
The thing that you have to do, is to compare the current section id of the event, with the section of the original one(before changes started), and show some modal. Based on the choice (yes/no) you can restore the event’s data to the original one or keep it changes.
The code may look like follows:
var fromSec;
var currSec;
scheduler.attachEvent("onBeforeEventChanged", function(ev, e, is_new, original){
fromSec = original.section_id;
currSec = ev.section_id;
if(fromSec != currSec){
dhtmlx.modalbox({
text: `Do you want to move event from section ${fromSec} to ${currSec}`,
width: "500px",
position: "middle",
buttons:["Nope", "Yes" ],
callback: function(index) {
switch(+index) {
case 0:
ev.section_id = original.section_id;
ev.start_date = original.start_date;
ev.end_date = original.end_date;
scheduler.updateView()
break;
case 1:
break;
}
}
});
}
return true;
});
Here is a demo:
http://snippet.dhtmlx.com/5/ca5f138dd
Thank you for your reply, great tip and answer