New to Kendo UI for jQuery? Download free 30-day trial

Prevent the Dragging of Nodes to the Root TreeView Level


Product Progress® Kendo UI® TreeView for jQuery
Operating System Windows 10 64bit
Visual Studio Version Visual Studio 2017
Preferred Language JavaScript


How can I prevent the nodes from being dragged to the root tree level of the Kendo UI for jQuery TreeView?


The following example demonstrates how to handle the drag event to achieve this behavior.

    <div id="tree"></div>

        dragAndDrop: true,
        dataSource: [
          { text: "root 1", expanded: true, items: [
            { text: "bar", expanded: true, items: [
              { text: "baz" },
              { text: "foo" }
            ] }
          ] },
          { text: "root 2" }
        drag: function(e) {
          if (e.statusClass == "denied") {
            // The TreeView already denies this operation.
          } else {
            // Whether the action is related to a root node.
            var targetsRoot = $(e.dropTarget).parentsUntil(".k-treeview", ".k-item").length == 1;

            // If targeting a root node and the operation is not add.
            // This means that the operation is to insert before or after the root
            //  which will create another root.
            if (targetsRoot && e.statusClass != "add") {

See Also

In this article