DataView drag-n-drop copy item between views

Hi

I need to complete d-n-d functionality between two dataviews. By default the dragged and dropped item is moved to the target view. I need it just being copied (not removing from the source). I figured I need to use onBeforeDrop event for the target object (am I right here?).

I use the code as follows

dataX.attachEvent("onBeforeDrop",function(context){ //custom data moving this.move(context.source, this.indexById(context.target)); return false; //block default processing });
but it appears that context.target is always null then.

How should I approach that?

Hi,

I have made few changes in your code… Please try the following:

dataX.attachEvent(“onBeforeDrop”,function(context){
if(context.from)
context.from.copy(context.start, context.index, this);
return false; //block default processing
});

Thanks Alexandra - it did the trick! :slight_smile:

I however added a slight modification to the code, in order to copy drags from another view but move drags within the same view. Like this:

[code] dataX.attachEvent(“onBeforeDrop”,function(context){
if(context.from){
if( context.from == context.to )
context.from.move(context.start, context.index, this);
else
context.from.copy(context.start, context.index, this);
}

	return false; //block default processing
});[/code]

Maybe somebody could use the code too :wink: