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

Possible Bug: Drag and Drop always removes and adds databound object

4 Answers 76 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Seth
Top achievements
Rank 1
Seth asked on 18 Jun 2009, 01:25 PM
I am using a databound Treeview and I am trying to enable drag and drop so that the user can change the order of a workflow.  This control is deleting then re-adding the object on drag and drop, rather then just changing it's position.  This is creating an edit level mismatch when I try to save the updated the updated treeview.  Will this behavior be changed for new versions of the Treeview?

Thanks,
Seth

4 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 21 Jun 2009, 09:30 PM
Hi Seth,

Unfortunately the .NET collections (and collection interfaces) do not offer a way to move an item. The TreeView just casts the ItemsSource or  Items collection (whichever is in use) to an IList and then removes the item from the source collection and adds it to the destination collection. With the current collection implementations the most we can do is replace an item, but that does not help much during drag/drop where you indeed move an item.

If you are using a custom items source that does support moving items, the Q2 version of the TreeView will allow you to customize how the TreeView reacts to a successful drag/drop.

We will appreciate any feedback on how we can improve the default behavior.

Regards,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Kenneth
Top achievements
Rank 1
answered on 16 Jan 2010, 05:17 PM
Have similar problem.

When moving nodes within a treeview - works as needed. When moving a node to a different control (a gridview) I do not want to remove the item from collection associated with the treeview, I need to copy the object and insert it into the collection associated with the gridview.

Basically, I need to customize the behavior under certain circumstances, to make the result of the dragdrop to be a copy, not a move.

Don't expect there to be an easy answer, but have attempted to inspect the state of the various events to see if I could find a point where the drag source and drop destination are known - before the the item is removed from source collection. My idea was that I could get the index of the item, copy it, and reinsert it at the appropriate point. But was not able to find an event that gave me that chance.

Is there are way to accomplish the above, or perhaps a better way to customize the dragdrop behavior to accomplish this?

Thanks,
Ken
0
Ivan
Telerik team
answered on 21 Jan 2010, 10:52 PM
Hello Kenneth,

I am sorry for this very late response.

Please keep an eye on this thread - we will prepare an example and will post it here.
 
Thank you for your patience

Regards,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ivan
Telerik team
answered on 25 Jan 2010, 07:32 AM
Hi Kenneth,

If you want to have a copy-drag you should mark the event as Handled in order to prevent removing of the source item:
 
private void radTreeView_PreviewDragEnded( object sender, RadTreeViewDragEndedEventArgs e )
{
   e.Handled = true;
}
 
The copy-case is described in the How to Implement Copy Drag article. Please follow it and let us know if you have other questions.


Best wishes,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
Seth
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Kenneth
Top achievements
Rank 1
Ivan
Telerik team
Share this question
or