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

How to implement something like "IsDroppingAllowed " with RadTreeView

1 Answer 57 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
koala
Top achievements
Rank 1
koala asked on 21 Apr 2015, 01:02 PM

I have a RadTreeView with some Containers and some Items (the items do not contain other items). When I activate Drag and Drop everything works fine. My problem is that I have some Containers that should not work as drop target. Unfortunatly I could not find an example.

First I tried the property IsDroppingAllowed (I used it like IsExpanded and IsSelected). Unfortunatly the getter is never called.

Than I tried "OnDragOver"

DragDropManager.AddDragOverHandler(this.FolderRadTreeView, new Telerik.Windows.DragDrop.DragEventHandler(OnDragOver), true);

It seems that I have to set 
options.DropAction = DropAction.Move;

or

options.DropAction = DropAction.None;

and everything works fine. But after a while it drives me crazy. Is there anywhere a good example? Is there anywhere a checklist what I have to reimplement? 

I tried to use the DropTargetItem to check if the dropping is allowed.

var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions;
var dropItem = options.DropTargetItem.Item;
(dropItem as IFolderItem).IsDroppable(options.DraggedItems));

If I drop inside everthing is fine. If I drop before (Telerik.Windows.Controls.DropPosition.
Before) it seems that my dropItem I used for IsDroppable() is not the container where the RadTreeView drops my item. 

An other trapdoor it that I have to check that I do not drag an Item in itself (drag A and drop it in A or drop in a child of A).

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 22 Apr 2015, 10:35 AM
Hi Koala,

You can use the IsDropAllowed property of the RadTreeViewItem to disable the drop operation of the specific item. This approach is described in the Disable Drop at Specific Location help article. I also attached a sample project demonstrating such approach.

Regards,
Martin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
TreeView
Asked by
koala
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or