kendo ui treeview dragend获取节点ID

 测试帐号 发布于 2023-02-12 18:17

我有这个函数来捕获剑道树视图的拖动结束事件

function onDragEnd(e) {
 console.log("Drag end", e.sourceNode, e.dropPosition, e.sourceNode);
}

这将显示整个节点数据,例如

  • [node text]
  • 还有这个函数来获取节点的文本.

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

    我希望有类似的东西

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

    会工作,但它没有,

    1 个回答
    • 树视图

      $("#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)
          }
      });
      

      2023-02-12 18:20 回答
    撰写答案
    今天,你开发时遇到什么问题呢?
    立即提问
    热门标签
    PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
    Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有