[英]How to get the dataitem from e.target in the onDrag method of a Kendo TreeList (in Javascript)?
我有一個onDrag
方法綁定到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)
但是只要它能正常工作!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.