Php 从kendo treeview所选节点检索id

Php 从kendo treeview所选节点检索id,php,kendo-ui,kendo-treeview,Php,Kendo Ui,Kendo Treeview,我有这种情况 1) 服务器端返回一个json编码的数组,其中包含不同的字段以及主键,即id。 2) 一个剑道树视图就是从这个json创建的 三, 我想这样做 1) 用户浏览树并选择一个节点。 2) 我希望找到树的主id或从服务器端传递的任何其他字段,以区分所选节点 我希望我能回答这个问题。 提前感谢。将您的功能定义为: select : function (e) { // Get clicked node var node = e.node; // Find it'

我有这种情况

1) 服务器端返回一个json编码的数组,其中包含不同的字段以及主键,即id。 2) 一个剑道树视图就是从这个json创建的 三,

我想这样做

1) 用户浏览树并选择一个节点。 2) 我希望找到树的主id或从服务器端传递的任何其他字段,以区分所选节点

我希望我能回答这个问题。
提前感谢。

将您的
功能定义为:

select    : function (e) {
    // Get clicked node
    var node = e.node;
    // Find it's UID
    var uid = $(node).closest("li").data("uid");
    // Get the item that has this UID
    var item = this.dataSource.getByUid(uid);
}

将您的
选择功能定义为:

select    : function (e) {
    // Get clicked node
    var node = e.node;
    // Find it's UID
    var uid = $(node).closest("li").data("uid");
    // Get the item that has this UID
    var item = this.dataSource.getByUid(uid);
}

对于find uid,可以通过e.node属性找到它

     select    : function (e) {  
    var uid = e.node.attributes['data-uid'].value;
                var dataItem = this.dataSource.getByUid(uid);
                alert(dataItem.ProductName);
       }

对于find uid,可以通过e.node属性找到它

     select    : function (e) {  
    var uid = e.node.attributes['data-uid'].value;
                var dataItem = this.dataSource.getByUid(uid);
                alert(dataItem.ProductName);
       }

下面是另一个解决方案:

onSelect: function(e) {
    var treeView = e.sender,
        dataItem = treeView.dataItem(e.node);
    console.log(dataItem.id);  // retrieves an ID of selected node
}

下面是另一个解决方案:

onSelect: function(e) {
    var treeView = e.sender,
        dataItem = treeView.dataItem(e.node);
    console.log(dataItem.id);  // retrieves an ID of selected node
}