Dragging in TreeView - hover text to "drop inside" a level when hovering over child items

5 posts, 1 answers
  1. jen
    jen avatar
    63 posts
    Member since:
    Jun 2009

    Posted 02 Feb 2012 Link to this post

    So I'm trying to do something a little different with my drag and drop. I have a RadTreeView control to group "Reports" into "Sets". I am only allowing "Reports" to be dragged and they can only be dropped inside a "Set". When I have a Set expanded, and I drag a Report over the Set OR any of the reports currently in that set, I'd like the hover text to say "Drop in Set x".

    I've got this half working, using the DragDropQueryEvent. If the destination's parent is a Set, I change the destination to the set and the drop position to Inside.

    This works for the first time hovering over the reports inside a set, but the next time I hover over the same objects the text becomes "Drop After Set x". As far as I can tell, the same code is being run. The drop is occurring in the right place, but the text isn't correct.

    Any insight into what's happening, or another way to get this behaviour is greatly appreciated!


    Below is some simplified code of my DragDropQueryEvent

     private void DragQuery_CanDrop(object sender, DragDropQueryEventArgs e)
    {
                var treeViewItem = e.Options.Destination as RadTreeViewItem;

                if (treeViewItem != null)
                {

                    if (treeViewItem.Item is Set )
                    {

                        if (treeViewItem.DropPosition == DropPosition.Inside) //can only drop INSIDE set 
                        {
                           ....
                            e.QueryResult = true;
                        }
                        else
                        {
                            e.QueryResult = false;
                        }

                    }
                    else if (treeViewItem.Item is Report)
                    {

                        if (treeViewItem.ParentItem != null && treeViewItem.ParentItem.Item is Set)
                        {
                            e.Options.Destination = treeViewItem.ParentItem;
                            treeViewItem.DropPosition = DropPosition.Inside;

                           ...
                           e.QueryResult = true;
                        }
                        else
                        {
                            e.QueryResult = false;
                        }
                    }
                    else
                    {
                        e.QueryResult = false;
                    }
        }
    }


  2. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 06 Feb 2012 Link to this post

    Hello,

     I have prepared sample based on the info provided. Would it be possible to check whether this is the expected behavior and if the project helps. If, not would it be possible to shhare some additional information regarding the desired behavior as well as the version you are currecntly using.


    All the best,
    Tsvyatko
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. jen
    jen avatar
    63 posts
    Member since:
    Jun 2009

    Posted 06 Feb 2012 Link to this post

    Thanks for the project, I made a change and now its working far enough to demenstrate the issue.
     

    the change to make the code work:

    else if (((Item)treeViewItem.Item).Title.Contains("Report")) 
    {
        if (treeViewItem.ParentItem != null && ((Item)treeViewItem.ParentItem.Item).Title.Contains("Set"))
              {


    follow these steps to see the issue
    1. Put a report into a set, expand the set so the report is visible.
    2. Drag another report over the report within the set and the text shows "Drop inside Set" - as expected
    3. Continue draging the report around and bring it back over the report in the set a second time and the text becomes "Drop after set" instead of "drop inside set"

    I'd like the text to keep saying "drop inside set" whenever you drag over the child reports, instead of just the first time wich its currently doing.

                    

  5. Answer
    Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 07 Feb 2012 Link to this post

    Hi,

     We were able to reproduce the same behavior from our side. The issue is casued by the fact that e.Options.Destination is altered in dropquery. This interferes with the dropindicator logic. I have modified the project to remove the undesired drop indicator.


    Please have a lok and let us know if this helps.

    Regards,
    Tsvyatko
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. jen
    jen avatar
    63 posts
    Member since:
    Jun 2009

    Posted 07 Feb 2012 Link to this post

    Thanks again for the project. The issue still continues, but I've tried a different idea that will work in this case.

    Since I only have one drop case, I changed the TextDropAfter, TextDropBefore properties to read "Drop Inside" and hid the Drop preview line. Now it appears to work as expected, and the drop is occuring in the right place.

    Thanks again for your assistance!
Back to Top
DevCraft banner