如何在Kendo TreeList(在Javascript中)的onDrag方法中从e.target获取数据项



我有一个绑定到treeList的拖动事件的onDrag方法。在这个方法中,我需要在用户拖动的tr中获取数据项。但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");
};

这感觉像是作弊,但如果人们在这里搜索并登陆,我也会在这里给出答案:为了在拖动事件中获取dataItem,我使用了一段丑陋的代码:

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

但只要它有效!

相关内容

最新更新