get the date and time by ondrop event in scheduler

Hi
i need to get the date and time from the scheduler ondrop event. I am using prototype drag and drop functionality to drop and drop event in the scheduler and call the Ajax updater to update in the database.

the problem is i can pass the event name dymamically. i need to to get the date and time of the mouse drop co ordinates.

using the prototype drag and drop functionality i can call some method on onDrop of js to update the database.

my code is below…

onDrop: moveItem

function moveItem( draggable,droparea){
draggable.parentNode.removeChild(draggable);
scheduler.attachEvent(“onmouseup”, madhan());
}

function madhan() {
alert(‘on Drop’);
dhtmlxEvent(scheduler._els[“dhx_cal_data”][0],“mouseup”,function(e){
e = e||event;
var pos = scheduler._mouse_coords(e);
var timestamp = scheduler._min_date.valueOf()+(pos.y*scheduler.config.time_step+(scheduler._table_view?0:pos.x)2460)*60000;
alert(timestamp);
});

}

i am not getting the timestamp.
but alert message “on Drop” is coming…

Scheduler has some native “onmouseup” handler , assigned to the data-area , which can block any other custom events.

The next can be used to include a custom code in the call chain.

var old = scheduler._on_mouse_up; scheduler._on_mouse_up = function(e){ //custom code here return old.apply(this,arguments); }

Can you provide some more details, why do you need an onDrop event?

hello stanislav,
Thank you for your reply. My requirement is , when the user drag the event name from the external div and drop inside the scheduler , need to get the onDrop coordinates in the scheduler and get the date and time according to that ondrop mouse coordinates and update the event in the database.

Thanks
Madhan

Hi,
I have the same requirement as you, so you can override get_value function in scheduler.form_blocks[“time”].get_value to get your current time.

Below was a sample for you refer:
var currentStart;
var currentEnd;
get_value:function(document,currentStart, currentEnd){
s=document.getElementsByTagName(“select”);
currentStart=new Date(s[3].value,s[2].value,s[1].value,0,s[0].value);
currentEnd=new Date(s[7].value,s[6].value,s[5].value,0,s[4].value);
}

Judo

thanks judo for reply.

you are getting the start and end time from the select box, but i need to get the start time from onDrop event, that too from drag event name from the external div to inside the scheduler.

Best Wishes
Madhan

Attached sample shows one of possible solutions.
scheduler_drag_in.zip (46.3 KB)

Hi Stanislav,

Can you do the same when removing an event from the view?

ie. drag it off the grid and onto the white space at the bottom?

Cheers.

Hi,
I got this error “object does not support this property” in line start = this._correct_shift(start); . Do you have any idea?

Thanks
karthick

Component detects only mouse actions inside the view area, so you will not be able to detect mouse-out-of-view events through API.

It possible to save details of dragged event form onBeforeDrag event and use custom dom handler for mouse out detection

Hi, I got this error "object does not support this property" in line start = this._correct_shift(start); . Do you have any idea?
Update your codebase to the version 2.2

Stanislav, I used this code:

var node = document.getElementById('drag_me'); (new dhtmlDragAndDropObject()).addDraggableItem(node,{ _createDragNode:function(node){ var dragSpan=node.cloneNode(true); dragSpan.style.position="absolute"; dragSpan.style.zIndex=12; return dragSpan; }, }); node.dragLanding=false;

but IE complains and displays the following:

“Expected identifier, string or number”.

Do you have any ideas how this could be resolved please? It works lovely in FF.

Cheers.

It really not related to component, just an extra comma

return dragSpan; }//remove comma here

Doh! Great thank you very much and sorry to disturb you.