我是这样做的:
@(Html.Kendo().TreeView()
.Name("treeview")
.DragAndDrop(true)
.Events(events=>events.Drop("onDrop"))
.HtmlAttributes(new{@class="demo-section"})
.DataTextField("Name")
.DataSource(dataSource=>datasource.Read(read=>read.Action("Employees","Remote_Data"))))
脚本代码:
function onDrop(e){
var treeview=$("#treeview").data("kendoTreeView");
var destination=$(e.destinationNode);
var treeItem={
Name:treeview.text(e.sourceNode),
tagId:e.sourceNode.tagId
};
if (e.valid && destination.length > 0) {
if (e.dropPosition == "over") {
rightTree.append(treeItem, destination);
rightTree.expand(e.destinationNode);
}
else if (e.dropPosition == "before") {
rightTree.insertBefore(treeItem, destination);
}
else if (e.dropPosition == "after") {
rightTree.insertAfter(treeItem, destination);
}
}
else {
rightTree.append(treeItem, null);
$('#NoItemsMessage').hide();
}
e.setValid(false);
}