Completed
Last Updated: 13 Mar 2024 08:49 by ADMIN
Release 2024.1.312
Martin
Created on: 20 Mar 2023 15:40
Category: TreeView
Type: Bug Report
0
RadTreeView.DragEnding does not cancel the expansion of the target node.

Repro-steps:

  1. Create a RadTreeView
  2. Set the TreeViewElement.ExpandTimerInterval to forever (so never auto expand by the timer).
  3. Enable drag/drop.
  4. Create an event handler for RadTreeView.DragEnding and make it cancel the drop operation.
  5. Fill the tree with random nodes and childnodes
  6. Drag and drop a node to collapsed node with children.

Observed behavior:

  1. The node is not dropped but the target node is expanded..

Expected behavior:

  1. The node is not dropped but the target node is NOT expanded, since the operation is cancelled.

 

4 comments
ADMIN
Dinko | Tech Support Engineer
Posted on: 29 Mar 2023 13:42

Hello Martin,

You have a point here. After a brief discussion with the development team regarding your scenario, we can agree that this behavior could be improved. It is not expected for the target node to expand when the drag-drop operation is canceled. Therefore I have changed the status of the feedback item. As a workaround, you may consider using the NodeExpandedChanging event handler to cancel the expand operation.

Your account has been credited with Telerik Points as a token of appreciation for bringing this to our attention.

Regards,
Dinko | Tech Support Engineer
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.

Martin
Posted on: 23 Mar 2023 12:48

Supplement:

Maybe this point should not be viewed from a technical point of view, but a more functional point of view:

  1. Which developer is happy that a target node is expanded when the drop has been cancelled?
  2. Which user is happy that a target node is expanded when the drop did not succeed?

With other words: Why is this by design?

Martin
Posted on: 23 Mar 2023 09:49

Hi Dinko,

I disagree or I misunderstand.

As far as I understand it, when you drag a node over another node, it is automatically expanded AFTER ExpandTimerInterval has elapsed. That is way I said in step 2: "Set the TreeViewElement.ExpandTimerInterval to forever". So this should disable the auto-expand behavior.

In this case, the auto expand is not trigger by the timer of by hovering over the node. In this case the auto expand is trigger by the drop. And I can imagine that when a node is dropped on another node, it is automatically expanded, but in my case, the drop is cancelled. So no need to expand.

 

 

ADMIN
Dinko | Tech Support Engineer
Posted on: 23 Mar 2023 09:41

Hello Martin,

This is the default behavior. When a dragged node is dragged over a collapsed node, it will automatically expand. To suppress this, you can subscribe to the NodeExpandedChanging event and cancel the node expanding. You can raise a flag in the DragEnding event handler. Check the following code snippet. You can also check the last section in the Cancel a Drag and Drop Operation help article.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.radTreeView1.TreeViewElement.ExpandTimerInterval = 5000;
        this.radTreeView1.DragEnding += RadTreeView1_DragEnding;
        this.radTreeView1.NodeExpandedChanging += RadTreeView1_NodeExpandedChanging;
    }

    private void RadTreeView1_NodeExpandedChanging(object sender, Telerik.WinControls.UI.RadTreeViewCancelEventArgs e)
    {
        Debug.WriteLine(radTreeView1.TreeViewElement.DragDropService.State);
        e.Cancel = cancelExpand;       
    }

    bool cancelExpand = false;
    private void RadTreeView1_DragEnding(object sender, Telerik.WinControls.UI.RadTreeViewDragCancelEventArgs e)
    {
        e.Cancel = cancelExpand = true;
    }
}

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.