Need More Info
Last Updated: 27 Mar 2023 12:48 by ADMIN
Martin
Created on: 20 Mar 2023 15:35
Category: TreeView
Type: Bug Report
0
RadTreeView.ExpandTimerInterval is not reset when dragging over several nodes

Repro-steps:

  1. Create a RadTreeView
  2. Set the TreeViewElement.ExpandTimerInterval to 5 seconds.
  3. Enable drag/drop.
  4. Fill the tree with random nodes and childnodes
  5. Drag a node over other nodes. Make sure you do not hover longer than 5 seconds over a single node. So just move around.

Observed behavior:

  1. After 5 seconds the node you are just hovering over, is expanding.

Expected behavior:

  1. No node will automatically expand. Every time a new node is hovered over, the timer will reset.


1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 27 Mar 2023 12:48

Hi, Martin,

By default, the ExpandTimerInterval property specifies the interval of time in milliseconds which will pass before a hovered node is being expanded during drag and drop operation. However, please have in mind that while dragging a node if the target node has children or DropPosition is AsChildNode, the same expand timer will be started. Hence, after the interval of 5s (for example) the node will be expanded even if the mouse position is over another node.

This is the default implementation for better explanation:

        protected override void OnPreviewDragOver(RadDragOverEventArgs e)
        {
            TreeNodeElement targetNodeElement = e.HitTarget as TreeNodeElement;
            RadTreeViewElement treeView = e.HitTarget as RadTreeViewElement;

            if (treeView != null)
            {
                e.CanDrop = treeView.ElementTree.Control.AllowDrop && treeView.Nodes.Count == 0 && this.IsInValidState(treeView);
            }
            else if (targetNodeElement != null)
            {
                DropPosition dropPosition = this.GetDropPosition(this.DropLocation, targetNodeElement);
                e.CanDrop = this.CanDragOver(dropPosition, targetNodeElement);

                RadTreeViewDragCancelEventArgs args = new RadTreeViewDragCancelEventArgs(draggedNode, targetNodeElement.Data);
                args.Cancel = !e.CanDrop;
                args.DropPosition = dropPosition;

                this.owner.OnDragOverNode(args);
                e.CanDrop = !args.Cancel;                
            }

            base.OnPreviewDragOver(e);
        }

In the CanDragOver method, the following logic is executed: 

            if (dropPosition == DropPosition.AsChildNode && !targetNode.Expanded && targetNode.HasNodes)
            {
                targetTreeView.AutoExpand(targetNode);
                this.HideHintWindow();
                this.ShowHintWindow();
            }
        protected virtual internal void AutoExpand(RadTreeNode node)
        {
            if (!node.Expanded)
            {
                this.expandTimer.Tag = node;
                this.expandTimer.Start();
            }
        }

Could you please specify how this situation should be handled according to your expectations if you want to restart the timer every time after a new node is hovered?

 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.