This is a migrated thread and some comments may be shown as answers.

Prevent node opening on Drag Drop

5 Answers 45 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 02 Jun 2008, 04:14 PM
Is there a way to prevent nodes from opening when a node is being dragged over it or to only open when the node is held over the +- portion of the node?

The opening seems to be almost random as sometimes a node will open while moving past another node and other times you can hold the dragged node over another node for several seconds with nothing happening.

5 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 03 Jun 2008, 11:25 AM
Hi Ryan,

Thank you for writing.

You can cancel expanding/collapsing nodes by handling the NodeExpandedChanging event of RadTreeView as shown below:

private bool treeViewDragging = false
 
void radTreeView1_DragEnding(object sender, RadTreeViewDragCancelEventArgs e) 
    this.treeViewDragging = false
 
void radTreeView1_DragStarted(object sender, RadTreeViewDragEventArgs e) 
    this.treeViewDragging = true
 
void radTreeView1_NodeExpandedChanging(object sender, RadTreeViewCancelEventArgs e) 
    if (this.treeViewDragging) 
    { 
        e.Cancel = true
    } 

I hope this helps. If you have additional questions, please contact me.

Kind regards,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ryan
Top achievements
Rank 1
answered on 05 Jun 2008, 03:02 PM
This is how I was originally doing it but there is a problem.  The drag ending/ended event doesn't fire if a node is dropped off of the treeview.  Is there a workaround to take into account the user cancelling the drag drop by dropping the node outside of the treeview?
0
Ryan
Top achievements
Rank 1
answered on 05 Jun 2008, 03:16 PM
I looked in the source code for the RadTreeView and the ResetDragging function gets called if a drag is cancelled and this function does not trigger the Drag Ending or Drag Ended events.  Is there a reason that this does not happen or would it be safe for me to add this functionality into the ResetDragging function?
0
Accepted
Jordan
Telerik team
answered on 06 Jun 2008, 07:38 AM
Hi Ryan,

You could try adding this functionality into the ResetDragging function, but I recommend against it. The reason is, you'll have to modify the source of RadTreeView, and we we would not be able to support the component in your case, as per the license agreement. I recommend using the MouseUp event (which is always fired, and is fired after the drag and drop operation ends) of RadTreeView instead of the DragEnding event.

Currently, the DragEnding and DragEnded pair of events is used to notify of a successful drag of a node.
You are correct - currently, there is no way to know when a drag and drop operation ends unsuccessfuly. We will add such an event for the upcomming 2008 Q2 release to handle this scenario.

Your Telerik points have been updated. Contact us again if you have any further questions.

Best wishes,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ryan
Top achievements
Rank 1
answered on 06 Jun 2008, 03:29 PM
Thank you the MouseUp event works for what I need
Tags
Treeview
Asked by
Ryan
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or