This is a migrated thread and some comments may be shown as answers.

Limit TreeView depth during drag and drop

1 Answer 329 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
bman
Top achievements
Rank 1
bman asked on 13 May 2016, 09:34 PM

I have two TreeViews which have drag and drop enabled. I am trying to limit the depth when someone tries to drag a branch to the other tree.

Example:

TreeA (root)

  TreeA.1.0 (child; level 1)

    TreeA.1.1 (child; level 2)

 

TreeB (root)

  TreeB.1.0 (child; level 1)

    TreeB.1.1 (child; level 2)

 

Given the above two trees and I desire to only have nodes up to 3 levels deep (ie. no deeper than child level 2) If a user drags "TreeB.1.0" under "TreeA.1.1" then TreeA will have children 4 levels deep.

I see events Drag and Drop which allow me to validate the destination tree to prevent this. I tried to implement custom data elements as HtmlAttributes in my OnDemand TreeViewItemModel DataSource in server-side code:

TreeViewItemModel node = new TreeViewItemModel();

...

node.HtmlAttributes.Add(new KeyValuePair<string, string>("data_level", level.ToString()));

 

This

 

1 Answer, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 16 May 2016, 07:58 AM
Hi Brian,

Did you review the  following blog post, which discusses a similar topic:

http://blog.falafel.com/restricting-drag-drop-levels-for-kendo-ui-treeview/

Regards,
Helen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
bman
Top achievements
Rank 1
Answers by
Helen
Telerik team
Share this question
or