Problem with image icons in TreeView

2 posts, 0 answers
  1. Igor Ashmetkov
    Igor Ashmetkov avatar
    12 posts
    Member since:
    Oct 2008

    Posted 09 Oct 2008 Link to this post

    Hello. I have this code to change image icons in the TreeView by client-side.
    When I press button - icons are changes (to "image.gif"), but when I select row 1, 2 or 3 there icons are change back to "folder.gif". What I need to do to stay icons "image.gif" after selecting TreeView row?

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="treeViewSetImage.aspx.cs"
        Inherits="treeViewSetImage" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <head runat="server">
        <title>Untitled Page</title>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
                <telerik:RadTreeView ID="tvwUserWorkout" runat="server">
                        <telerik:RadTreeNode Text="node1" ImageUrl="Images/folder.gif" />
                        <telerik:RadTreeNode Text="node2" ImageUrl="Images/folder.gif" />
                        <telerik:RadTreeNode Text="node3" ImageUrl="Images/folder.gif" />
                        <telerik:RadTreeNode Text="node4" />
                        <telerik:RadTreeNode Text="node5" />
            <input type="button" onclick="OnNodeEdited('new text','Images/image.gif')" value="Change image and text" />

        <script type="text/javascript">
            function OnNodeEdited(nodetext,imageurl)   
                var tree = $find("<%= tvwUserWorkout.ClientID %>");    
                for (var i = 0; i < tree.get_nodes().get_count(); i++) {   
                    var node = tree.get_nodes().getNode(i);        

  2. Yana
    Yana avatar
    4813 posts

    Posted 10 Oct 2008 Link to this post


    Please modify OnNodeEdited method like this:

    function OnNodeEdited(nodetext,imageurl)     
      var tree = $find("<%= tvwUserWorkout.ClientID %>");      
      for (var i = 0; i < tree.get_nodes().get_count(); i++) {     
        var node = tree.get_nodes().getNode(i);          

    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top