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

Drag & Drop duplicat items

6 Answers 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kacem
Top achievements
Rank 1
Kacem asked on 15 Aug 2011, 03:50 PM
Hi,
I have a Treeveiw bound to an ObservableCollection TheClassifications :
<telerik:RadTreeView Grid.Column="2"
            SelectionMode="Multiple" IsLineEnabled="True" IsExpandOnDblClickEnabled="True" IsExpandOnSingleClickEnabled="True" IsSingleExpandPath="False" IsDragDropEnabled="True"
            IsRootLinesEnabled="True" Margin="10" x:Name="RadTreeView1" IsTriStateMode="True"
            ItemsSource="{Binding TheClassifications, Mode=TwoWay}"
            ItemTemplate="{StaticResource myTelerikHierarchicalTemplate}" />

ObservableCollection<ClassificationItem> TheClassifications_;
        public ObservableCollection<ClassificationItem> TheClassifications
        {
            get { return TheClassifications_; }
            set { SetObjValue(TheClassifications_, value, x => TheClassifications_ = x, () => TheClassifications); }
        }

I have 2 problems :
1- I can drop elements only on the root node
2- The droped elements are duplicated
I'll attach a screenshot to show you those problems...

How can I fix it ?
Thanks
Kacem

6 Answers, 1 is accepted

Sort by
0
Kacem
Top achievements
Rank 1
answered on 16 Aug 2011, 05:18 PM
I think I know what's the problem.
I'm using Ria Services SP1 and my collection is an EntityCollection, so I can't change it :(

Is there any issue ?
0
Fabien
Top achievements
Rank 1
answered on 16 Aug 2011, 07:23 PM
Hi, I think you have to enable the Drag&Drop on each sub element (using a Style), and not only on the TreeView
0
Kacem
Top achievements
Rank 1
answered on 17 Aug 2011, 08:55 AM
@Fabien : No I don't think so, on demos they enable drag&drop one time ...

Edit : 
This post may help others : http://www.telerik.com/community/forums/silverlight/treeview/can-not-drag-drop-the-radtreeview-nodes.aspx#1019981
0
Petar Mladenov
Telerik team
answered on 18 Aug 2011, 08:45 AM
Hello Kacem,

 When using Drag'n'Drop it's important that the ItemsSource colelction of the TreeView is ObservableCollections and the destination item's child collection is already initialized. When working with services that return IEnumerable, you can create a wrapper classes that use ObservableCollections. In this blog post you can check out how this could be achieved. 

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Kacem
Top achievements
Rank 1
answered on 18 Aug 2011, 10:40 AM
I prefer bind my Treeview directly to ria services collection...
Is there any way to manage Add/Remove operations myself ?
With RadTreeView I can't drop any elements on my nodes, so the idea is to allow drop and manage the operations myself ...

Thanks
Kacem
0
Petar Mladenov
Telerik team
answered on 23 Aug 2011, 03:45 PM
Hi Kacem,

 The way to manage the CRUD operations on your own is to handle the RadDragAndDropManager's events in the RadTreeView. You can find more info on how to work with these events in this documentation article.
Please let us know if you need more info on this.

Regards,
Petar Mladenov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
TreeView
Asked by
Kacem
Top achievements
Rank 1
Answers by
Kacem
Top achievements
Rank 1
Fabien
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or