简体   繁体   English

在Kendo UI树视图之前和之后限制dropPosotion

[英]Restrict dropPosotion before and after Kendo UI treeview

When doing drag and drop in Kendo UI TreeView it has 3 positions namely "before", "over" and "after". 在Kendo UI TreeView中进行拖放操作时,它有3个位置,即“之前”,“之上”和“之后”。

http://docs.kendoui.com/api/web/treeview#dragend http://docs.kendoui.c​​om/api/web/treeview#dragend

Is it possible to restrict the "before" and "after" states and only allow drop "over" functionality. 是否可以限制“之前”和“之后”状态,并且只允许“删除”功能。

Note 注意

In my scenario I have 2 trees and I'm dragging element from left tree to the other. 在我的场景中,我有2棵树,我将元素从左侧树拖到另一棵树。

In your kendoTreeView , define drag and drop event handlers as follow: 在你kendoTreeView ,定义dragdrop事件处理程序如下:

drag       : function (ev) {
    if (!$(ev.dropTarget).hasClass("k-in k-state-hover")) {
        ev.setStatusClass("k-denied")
    }
},
drop       : function (ev) {
    if (ev.sourceNode === ev.destinationNode) {
        ev.setValid(false);
    }
}

In the drag I check that we are over an element and if not I set that status class to k-denied that it formats the clue as denied but also prevents from dropping it there. drag我检查我们是否一个元素上,如果不是,我将该状态类设置为k-denied ,它将clue格式化为被拒绝,但也防止将其丢弃。

In the drop I just check that I'm not dropping on top of itself preventing a stack overflow. drop我只是检查我是不是自己在防止堆栈溢出。

Running example here: http://jsfiddle.net/OnaBai/mu92b/ 在这里运行示例: http//jsfiddle.net/OnaBai/mu92b/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM