gpt4 book ai didi

javascript - kendo ui treeview dragend 获取节点id

转载 作者:行者123 更新时间:2023-11-29 17:13:02 24 4
gpt4 key购买 nike

我有这个函数来捕捉剑道 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 class="k-in">[node text]</span>
</div>
</li>

还有这个函数可以获取节点的文本。

var text = this.text(e.sourceNode);

我希望是这样的

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)
}
});

关于javascript - kendo ui treeview dragend 获取节点id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20393473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com