dhtmlxTree_outer_drag question

Hi There -
I’d like to do something similar to the 02_dhtmlxTree_outer_drag example. Except that instead of creating a new event when dragging in from the Tree list, I’d like to detect if the item was dragged onto an already existing event. So is there a simple way to detect that in the function within the attachEvent(“onExternalDragIn”, …
And also detect the event id that it was dropped on?
Thanks in advance,


Update files from the attached archive.
Then you can do following:

scheduler.attachEvent("onExternalDragIn", function(id, source, e) { var label = tree.getItemText(tree._dragged[0].id); console.log(arguments) var actionData = scheduler.getActionData(e); var date = actionData.date; var events = scheduler.getEvents(date, date); // console.log(events); scheduler.getEvent(id).text = label; return true; });
Kind regards,

Attached archive?

Grab files in question by the next link

s3.amazonaws.com/uploads.hipcha … 130104.zip

I currently am using v.3.5 build 120823. I’ve made a few changes to some files. Do I necessarily need to have this newer version for this to work?

There is no major changes, just the onExternalDragIn event call is updated

[code]diff --git a/sources/ext/outerdrag.js b/sources/ext/outerdrag.js
index 7fbe09e…b37fddf 100644
— a/sources/ext/outerdrag.js
+++ b/sources/ext/outerdrag.js
@@ -13,8 +13,8 @@ scheduler.attachEvent(“onTemplatesReady”, function() {
if (scheduler.checkEvent(“onBeforeExternalDragIn”) && !scheduler.callEvent(“onBeforeExternalDragIn”, [sourceHtmlObject, dhtmlObject, targetHtmlObject, targetHtml, last_event]))

  •   	var temp = scheduler.attachEvent("onEventCreated", function(id, e) {
  •   		if (!scheduler.callEvent("onExternalDragIn", [id, sourceHtmlObject, e])) {
  •   	var temp = scheduler.attachEvent("onEventCreated", function(id) {
  •   		if (!scheduler.callEvent("onExternalDragIn", [id, sourceHtmlObject, last_event])) {
      			this._drag_mode = this._drag_id = null;

@@ -50,4 +50,4 @@ scheduler.attachEvent(“onTemplatesReady”, function() {
return this;
\ No newline at end of file

Thanks for getting back to me.
So I updated the dhtmlxscheduler_outerdrag.js and replaced the scheduler.attachEvent(“onExternalDragIn” … routine in the 01_dhtmlxTree_outer_drag.html sample with what you sent me. That example starts in the Timeline view and when I do a drag from the book list to the timeline, I get the following error -
TypeError: this._drag_event is undefined … dhtmlxscheduler_timeline.js (line 29).

BTW - if I load it and go straight into the day view and do a drag, it works fine (going back into the timeline view after that then works).

Note, for what I’m trying to do with the dragin, I don’t need the timeline view. So I’m wondering if there’s a way that I can detect ONLY the event that the item (book in the sample) was dragged into. Since there can be multiple events scheduled at the same time, using what you suggested, i.e. -
var actionData = scheduler.getActionData(e);
var date = actionData.date;
var events = scheduler.getEvents(date, date);
is great if I want all the events that happen at that time, however, as I mentioned, I only want the single event that the item was dragged into.
Is there a way to do that? I’m a bit of a noob, so I’m hoping it’s something very straight forward.

The simple approach will be to check target of event object

scheduler.attachEvent("onExternalDragIn", function(is, source, ev){
    var target = ev.target || ev.srcElement;
    var id = target.getAttribute("event_id");
    if (id) alert("Drop on event "+id);

That works fine when I’m in the timeline view but the id (variable in your code) results in a null in the day or work view.

I figured it out. Bottom line is that I need to learn javascript properly. Since I’m a noob, I don’t know where to draw the line on what’s a scheduler or javascript question.