node[i].selected kendo treeview c# code example

Example 1: kendo treeview get selected node data

// First to which ever element you specified your treeview with its datasource
// Create a new variable of it:

var tv = $('.mytree').data('kendoTreeView');

// You can get the node that you select by calling select() on your treeview
var selected = tv.select();

// Then use your selected as a parameter in the dataItem() function.
var item = tv.dataItem(selected);

// Then you can see what kind of data is inside it by e.g.
console.log(item); // and opening the inspector and expanding your item object

// Or
alert(JSON.stringify(item));

// The object you specified in the data source will be shown with other useful variables.

// To see how to use the data source with json check http://jsfiddle.net/NZq4A/2/

Example 2: kendo treeview select

$("#treeview").find("ul > li").each(function () {
     var dataItem = treeView.dataItem($(this));
     console.log(dataItem);
});

Tags:

Misc Example