Shivanka
Shivanka

Reputation: 743

Auto scroll Kendo TreeView when dragging elements up and down

Wish if someone could give me a solution to make kendo grid auto scroll when dragging a TreeView element up or down.

Upvotes: 0

Views: 1955

Answers (1)

Hrishi
Hrishi

Reputation: 350

Attach a drag event handler to the treeview, and set the scrollTop of the element that is scrollable depending on the drag position.

for example if the treeViewHolderDivEdit (below) is your container of the treeview you can do below.

treeview.bind("drag", function (e) {

     var targetDataItem =  treeview.dataItem(e.dropTarget);
     if(targetDataItem != null || targetDataItem != undefined)
     {
             if(targetDataItem.text == "Root" && e.statusClass == "insert-top")
             {
             e.setStatusClass("k-denied");
             }
            //  $("#status").html(e.statusClass + "  "+targetDataItem.text );
     }
       var y = e.pageY - $("#treeViewHolderDivEdit").offset().top;
       $("#treeViewHolderDivEdit").scrollTop(y);

 });

Upvotes: 2

Related Questions