Edit this page

dragstart

Triggered before the dragging of a node starts.

Event Data

e.sourceNode Element

The node that will be dragged.

Example - subscribe to the "dragstart" event during initialization

<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
  dragAndDrop: true,
  dataSource: [
    { text: "foo", items: [
      { text: "bar" }
    ] }
  ],
  dragstart: function(e) {
    console.log("Drag start", e.sourceNode);
  }
});
</script>

Example - subscribe to the "dragstart" event after initialization

<div id="treeview"></div>
<script>
function tree_dragstart(e) {
  console.log("Drag start", e.sourceNode);
}
$("#treeview").kendoTreeView({
  dragAndDrop: true,
  dataSource: [
    { text: "foo", items: [
      { text: "bar" }
    ] }
  ]
});
var treeview = $("#treeview").data("kendoTreeView");
treeview.bind("dragstart", tree_dragstart);
</script>

Example - disable dragging of root nodes

<div id="treeview"></div>
<script>
$("#treeview").kendoTreeView({
  dragAndDrop: true,
  dataSource: [
    { text: "foo", items: [
      { text: "bar" }
    ] }
  ],
  dragstart: function(e) {
    if ($(e.sourceNode).parentsUntil(".k-treeview", ".k-item").length == 0) {
      e.preventDefault();
    }
  }
});
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy