简体   繁体   English

在Kendo UI TreeList中拖动节点时,如何更改图标/拖动提示?

[英]How can I change the icons/drag clue when dragging a node in Kendo UI TreeList?

When dragging a node in Kendo TreeList, it shows a plus-icon when e.target is valid (allowed to drop into) but shows a denied-icon when e.target is invalid (for example when you drag a node over itself or a child). 在Kendo TreeList中拖动节点时,如果e.target有效(允许插入),它会显示一个加号图标;但是当e.target无效时(例如,当您将节点拖动到自身或a上时,它会显示一个拒绝图标)。儿童)。 I defined some own conditions where it's denied to drop. 我定义了一些拒绝删除的条件。 Now, I want to change the icon to denied according to my rules, too. 现在,我也想根据我的规则将图标更改为拒绝。

For Tree View , there is the e.setStatusClass(k-denied) method for this. 对于Tree View ,有一个e.setStatusClass(k-denied)方法。 It does not work on a Tree List : https://docs.telerik.com/kendo-ui/api/javascript/ui/treeview/events/drag . 它不适用于树列表https : //docs.telerik.com/kendo-ui/api/javascript/ui/treeview/events/drag Is there something similar for TreeList? TreeList有类似的东西吗? In the docs, there isn't: https://docs.telerik.com/kendo-ui/api/javascript/ui/treelist/events/drag . 在文档中,没有: https : //docs.telerik.com/kendo-ui/api/javascript/ui/treelist/events/drag

-- -

Using an onDrag(e) method and accessing e.target gives a td . 使用onDrag(e)方法并访问e.target会给出td But I need the dataItem into the tr . 但是我需要将dataItem放入tr

I had the same problem and managed to solve it using the drag event ... 我有同样的问题,并设法通过拖动事件解决了...

I added a drag-function to the treelist: 我在树形列表中添加了一个拖动功能:

drag: function(e) {
    if ($(e.target).parents('#targetTreeList>div>table').length>0) {
        e.setStatus("k-i-plus");
    }
    else {
        e.setStatus("k-i-cancel");
    }
}

And it will change the icon when hovering over nodes in treelist with Id='targetTreeList', of course you can add your own logic (I checked that it was a root node as well)... 当将鼠标悬停在id ='targetTreeList'的树形列表中的节点上时,它将更改图标,当然,您可以添加自己的逻辑(我检查过它也是根节点)...

I hope I could help a little (my first answer here at stackoverflow...) 我希望可以有所帮助(我在这里的第一个答案在stackoverflow ...)

Edit: To get the dataitem you could use: 编辑:要获取数据项,您可以使用:

$(e.target).parents('.k-treelist').data('kendoTreeList').dataItem(e.target)

(lookes overcomplicated but that was the only way I got it to work)... (看起来过于复杂,但这是我让它工作的唯一方法)...

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

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