Disable drop before and drop after

7 posts, 1 answers
  1. Ben
    Ben avatar
    2 posts
    Member since:
    Apr 2011

    Posted 28 Apr 2011 Link to this post

    Hi,

    I'm currently using a RadTreeView with drag and drop function enabled. I implemented the dragended event with business logic for saving the changed stucture of the tree into the database. But I don't want to use the dropbefore and dropafter, how can I disable these actions.

    I've read previous post about disabling the drop before and drop after which was created in 2009.
    http://www.telerik.com/community/forums/silverlight/treeview/disable-drop-before-and-drop-after.aspx 
    This blog says that it will be possible in the next service pack (which must be released by now). But I can't figure out how.

    Thanks in advance

    Ben
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 03 May 2011 Link to this post

    Hello Ben,

    I prepared a sample project for you illustrating the desired approach. It basically follows this documentation article. Please let us know if this is exactly what you've expected. You can also check out the RadDragAndDropmanger help articles and demos.

    Regards,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Ben
    Ben avatar
    2 posts
    Member since:
    Apr 2011

    Posted 04 May 2011 Link to this post

    Hello Petar,

    The solution you provided works with a code behind file. What I forgot to say was that  I'm using telerik with the MVVM design pattern and Caliburn.Micro. If I attach the handler the way you provided it give me the following error: "Cannot convert from Telerik.windows.RoutedEvent to System.Windows.RoutedEvent".

    In your solution you checked if the dropPosition is inside and ignore any other dropPostionType. I used that part in the workaround I currently have, which is:

    Within the RadTreeView I disabled the previewLine and Tooltip.
    I implemented the DragEnded en PreviewDragEnded events for the RadTreeView in my ViewModel
    In the implementation of the PreviewDragEnded I set the DropPosition to DropPosition.Inside

    public void PreviewDragEnded(RadTreeViewDragEndedEventArgs e)
    {
        if (e.DraggedItems[0] != null && e.TargetDropItem.Item != null)
        {
            var dragDestinationItem = e.TargetDropItem;
            if (dragDestinationItem.DropPosition != DropPosition.Inside)
            {
                e.TargetDropItem.DropPosition = DropPosition.Inside;
            }
        }
        else
        {
            e.Handled = true;
        }
    }


    And in my DragEnded implementation the dropPostion is now always DropPosition,Inside

    Regards,

    Ben
  5. RoadWarrior
    RoadWarrior avatar
    45 posts
    Member since:
    Jan 2010

    Posted 24 Jul 2012 Link to this post

    Petar.  Your demo illustrates a major issue with Telerik's drag & drop.  The vertical row space which triggers the "Drop In Item X" diminishes with each additional row.  So while it is relatively easy to trigger a drop into "Item A" while dragging over, it get more more difficult as you go down the list.  Check the demo, you will not be able to drop into beyond "Item F".

    Please verify my findings.  Hopefully, you can provide a good workaround.  Thanks, ~Rick
  6. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 27 Jul 2012 Link to this post

    Hi Rick,

    I'm not sure I understand what you mean. I tested Peter's solution and I didin't encounter any difficulties while trying to drop inside any of the items. Can you please have a look at this screencast and let me know if I've missed something.

    Also, can you please check if your browser is zoomed, as in older versions of the RadTreeView control, this used to cause issues when calculating the mouse position based on which the DragTooltip is displayed. 

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. RoadWarrior
    RoadWarrior avatar
    45 posts
    Member since:
    Jan 2010

    Posted 27 Jul 2012 Link to this post

    Thank you Tina!  You are correct.  My browser was zoomed to 115% and am using Q1 2011.  Unfortunately, I am not sure I can upgrade at this time.  Is there a workaround short of an upgrade?  Thanks again.
  8. Ziev
    Ziev avatar
    10 posts
    Member since:
    Oct 2011

    Posted 09 Oct 2012 Link to this post

    Hi Ben,

    Just wanted to thank you for sharing this little piece of code, which helped me solved my own problem:

    I wanted to make the "Inside" position look and behave as an "After" position (including the preview line and all the rest).
    In other words, to cancel having the Inside position and have only Before and After positions with a smooth transition between them (no gap).
    Using your value override method did it!

    I don't think I would have thought about it by myself otherwise... so thanks again for sharing.

    Cheers,
    Ziev
Back to Top
DevCraft banner