简体   繁体   中英

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. In this method, I need to get the dataitem in the tr the user drags over. But e.target only gets the td element.

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:

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

But as long as it's working!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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