Search code examples
phpkendo-uikendo-treeview

retrieve id from kendo treeview selected node


I have this scenario.

1) Server Side returns a json encoded array having different fields in it along with primary key i.e., id. 2) A kendo treeview is created from that json 3

I want to do this,

1) User browse the tree and select a node. 2) I want to find the primary id of the tree or any other field that is passed from server side to distinguish the selected node.

I hope I deliver the question. Thanks in advance.


Solution

  • Define your select function as:

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