Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 剑道ui树状视图dragend获取节点id_Javascript_Asp.net Mvc_Kendo Ui_Treeview - Fatal编程技术网

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