Drag & Drop duplicat items

7 posts, 0 answers
  1. Kacem
    Kacem avatar
    8 posts
    Member since:
    Jul 2011

    Posted 15 Aug 2011 Link to this post

    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
  2. Kacem
    Kacem avatar
    8 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2011 Link to this post

    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 ?
  3. DevCraft banner
  4. Fabien
    Fabien avatar
    1 posts
    Member since:
    Jun 2010

    Posted 16 Aug 2011 Link to this post

    Hi, I think you have to enable the Drag&Drop on each sub element (using a Style), and not only on the TreeView
  5. Kacem
    Kacem avatar
    8 posts
    Member since:
    Jul 2011

    Posted 17 Aug 2011 Link to this post

    @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
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 18 Aug 2011 Link to this post

    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 >>

  7. Kacem
    Kacem avatar
    8 posts
    Member since:
    Jul 2011

    Posted 18 Aug 2011 Link to this post

    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
  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Aug 2011 Link to this post

    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 >>

Back to Top
DevCraft banner