New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Client Templates

  • Group A
  • Group B
  • Group C
  • Group D
RadTreeView now supports client templates. The templates are declared in the ClientNodeTemplate tag and support the following expressions for evaluating code:
  • #= ... # - Data - Evaluates the Javascript code expression or a string property from the data item and outputs the result in the template.
  • # ... # - Code - Evaluates the JavaScript code expression inside. Does not output value.
  • #: ... # - HTML-encode - Same as the data expression, but HTML-encodes the result.
The templates are applied automatically to all nodes loaded through web service. To apply a client template to an arbitrary node, you have to call the bindTemplate() function on that node:
    function addNode(nodeText) 
        var node = new Telerik.Web.UI.RadTreeNode();
        var tree = $find('<%=RadTreeView1.ClientID%>'); 
You can also assign a specific template to individual nodes on the client:
    function setTemplate(node) 
        node.set_clientTemplate("Node Text: #= Text #");
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="TreeView.Examples.Functionality.ClientTemplates.DefaultCS" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-thin">
        <telerik:RadTreeView RenderMode="Lightweight" ID="RadTreeView1"  runat="server">
            <img src="#= Value #" alt="#= Value #" />
            <span>#= Text #</span>
                <telerik:RadTreeNode Text="Group A" Value="A" ExpandMode="WebService">
                <telerik:RadTreeNode Text="Group B" Value="B" ExpandMode="WebService">
                <telerik:RadTreeNode Text="Group C" Value="C" ExpandMode="WebService">
                <telerik:RadTreeNode Text="Group D" Value="D" ExpandMode="WebService">
            <WebServiceSettings Path="defaultcs.aspx" Method="GetTeams">

Support & Learning Resources

Find Assistance