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

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

4 Answers 53 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
jen
Top achievements
Rank 1
jen asked on 02 Feb 2012, 04:00 PM
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;
                }
    }
}


4 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 06 Feb 2012, 02:57 PM
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 >>
0
jen
Top achievements
Rank 1
answered on 06 Feb 2012, 04:02 PM
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.

                

0
Accepted
Tsvyatko
Telerik team
answered on 07 Feb 2012, 03:30 PM
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 >>
0
jen
Top achievements
Rank 1
answered on 07 Feb 2012, 03:53 PM
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!
Tags
DragAndDrop
Asked by
jen
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
jen
Top achievements
Rank 1
Share this question
or