我有这个功能来捕捉剑道树视图的拖动结束事件
function onDragEnd(e) {
console.log("Drag end", e.sourceNode, e.dropPosition, e.sourceNode);
}
这将显示整个节点数据,例如
<li role="treeitem" class="k-item k-last" data-uid="[some guid]">
<div class="k-bot">
<span class="k-in">[node text]</span>
</div>
</li>
还有这个函数来获取节点的文本。
var text = this.text(e.sourceNode);
我希望像
这样的东西var id = this.id(e.sourceNode);
会起作用,但事实并非如此,
答案 0 :(得分:5)
的TreeView
$("#treeView").kendoTreeView({
dragAndDrop: true,
dataSource: treeViewDataSource,
dataTextField: "Name",
dragend: function(e) {
var tree = $(#treeView).data("kendowTreeview");
/* tree.dataItem accesses the item's model. You will be able to
access any field declared in your model*/
var movingItem = tree.dataItem(e.sourceNode);
var destinationItem = tree.dataItem(e.destinationNode);
/*Using firebug, console.log(movingItem) will elaborate better
as to what you have access in the object*/
var movingItemID = movingItem.id;
var destinationItemID = destinationItem.id;
//Get the same ID by movingItemID.MyID
//(if id:"MyID" set in dataSource's schema)
}
});