This example shows how to use the client-side API of Telerik TreeView for ASP.NET MVC.
To use the client-side API you should first retrieve the treeview client-side object. The following code snippet shows how to do this:
<script type="text/javascript">
function getTreeView(){
//"TreeView" is the value specified by the Name() method.
var treeview = $("#TreeView").data("tTreeView");
return treeview;
}
</script>
The available client-side methods are:
treeview.expand(node) - expands a treeview node.treeview.collapse(node) - collapses a treeview node.treeview.enable(node) - enables a treeview node.treeview.disable(node) - disables a treeview node.treeview.getItemText(node) - gets the text of a treeview node.treeview.getItemValue(node) - gets the value of a treeview node. If the value is not set, returns the node text.treeview.nodeCheck(node, isChecked) - checks/unchecks a treeview node that has a checkbox, depending on the value of isChecked.All of the above methods accept node as either a DOM element, jQuery selector or a jQuery object.