Reputation: 55
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.
Upvotes: 0
Views: 3076
Reputation: 895
here is another solution:
onSelect: function(e) {
var treeView = e.sender,
dataItem = treeView.dataItem(e.node);
console.log(dataItem.id); // retrieves an ID of selected node
}
Upvotes: 0
Reputation: 53
for find uid you can find it by e.node attribute
select : function (e) {
var uid = e.node.attributes['data-uid'].value;
var dataItem = this.dataSource.getByUid(uid);
alert(dataItem.ProductName);
}
Upvotes: 0
Reputation: 40887
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);
}
Upvotes: 4