How to add image to RadTreeNode

2 posts, 1 answers
  1. Shaza
    Shaza avatar
    19 posts
    Member since:
    Apr 2011

    Posted 17 Apr 2011 Link to this post

    Hey, I'm working on building a treeview dynamically based onClicked event for a menu item.
    '
    function onClicked(sender, eventArgs) {
     
    var treeView = $find("<%= RadTreeView1.ClientID %>");
     
    var selectedNode = treeView.get_selectedNode();        
     
    var node = new Telerik.Web.UI.RadTreeNode();
     
    var parent = treeView.get_selectedNode();
     node
    .Image= "~/Images/Folder-Add-icon.png";
     parent
    .get_nodes().add(node);
     treeView
    .commitChanges();
    }

    But, the problem is I'm not getting the image next to the node when I try to add it, what's the problem?'
  2. Answer
    Kate
    Admin
    Kate avatar
    1898 posts

    Posted 20 Apr 2011 Link to this post

    Hi Shaza,

    You could change your code as follows. I also attached a sample page demostrating how it works.
    function onClicked(sender, eventArgs) {
               var treeView = $find("<%= RadTreeView1.ClientID %>");
               var selectedNode = treeView.get_selectedNode();
               var node = new Telerik.Web.UI.RadTreeNode();
               var parent = treeView.get_selectedNode();
               node.set_imageUrl("images/Spell.gif");
               parent.get_nodes().add(node);
               treeView.commitChanges();
           }


    All the best,
    Kate
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top