[英]How to get the dataitem from e.target in the onDrag method of a Kendo TreeList (in Javascript)?
I have an onDrag
method bound to the drag-event of a treeList. 我有一个
onDrag
方法绑定到onDrag
的拖动事件。 In this method, I need to get the dataitem in the tr the user drags over. 在这种方法中,我需要在用户拖动的tr中获取数据项。 But
e.target
only gets the td element. 但是
e.target
只得到td元素。
exportObject.onDrag = function (e) {
console.log(e.target); //output is td element
//console.log(e.target.parentElement); //undefined
console.log(this); //same as e.target
//if(e.target.?ROW.DATAITEM?.SomeProp != "something") e.setStatus("k-i-cancel");
};
This feels like cheating, but if people searches and lands here, I make an answer here as well: To get a hold of dataItem in drag event I use a ugly piece of code: 这感觉像是在作弊,但是如果人们在这里搜索并着陆,我也会在此处做出答案:要在拖动事件中保留dataItem,我会使用一段丑陋的代码:
$(e.target).parents('.k-treelist').data('kendoTreeList').dataItem(e.target)
But as long as it's working! 但是只要它能正常工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.