evi*_*lom 2 javascript asp.net-mvc treeview kendo-ui
我有这个函数来捕获剑道树视图的拖动结束事件
function onDragEnd(e) {
console.log("Drag end", e.sourceNode, e.dropPosition, e.sourceNode);
}
Run Code Online (Sandbox Code Playgroud)
这将显示整个节点数据,例如
<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>
Run Code Online (Sandbox Code Playgroud)
还有这个函数来获取节点的文本.
var text = this.text(e.sourceNode);
Run Code Online (Sandbox Code Playgroud)
我希望有类似的东西
var id = this.id(e.sourceNode);
Run Code Online (Sandbox Code Playgroud)
会工作,但它没有,
树视图
$("#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)
}
});
Run Code Online (Sandbox Code Playgroud)