Javascript 剑道ui树状视图dragend获取节点id
我有这个函数来捕捉剑道树视图的拖动结束事件Javascript 剑道ui树状视图dragend获取节点id,javascript,asp.net-mvc,kendo-ui,treeview,Javascript,Asp.net Mvc,Kendo Ui,Treeview,我有这个函数来捕捉剑道树视图的拖动结束事件 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 c
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 id = this.id(e.sourceNode);
会起作用,但没有,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)
}
});
找到了此问题的解决方案:
var id=($('[tree_element]').data('kendoTreeView').dataItem(e.sourceNode)).id代码>var-tree=$(#treeView).data(“kendowTreeview”)
也可以写成var-tree=e.sender代码>
$("#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)
}
});