TreePanel shows only default Icons when TreePanel.AppendChild is used unless we set the IconFile

  1. #1

    TreePanel shows only default Icons when TreePanel.AppendChild is used unless we set the IconFile

    Hello , It seems when we build treePanel dynamically it shows only the default icons unless we explicitly set the icon file Node. The following example demonstrates this fact.

    Comment in the line starting with // IconFile .... (line 9) then it works properly. There should not be need for this since we give the icon in the constructor of the treenode anyway.

    <%@ Page Language="C#" %>
    
    <script  runat="server">
        
        protected override void OnLoad(EventArgs e)
        {
            var newNode = new Ext.Net.TreeNode("1", "test", Icon.Folder)
            {
               // IconFile = ResourceManager1.GetIconUrl(Icon.Folder)
            };
            
            TreePanel1.AppendChild("root", newNode);
        }
        
    </script>
    <%@ Import Namespace="System.Collections.Generic" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Multi Node TreePanel built using markup - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <h1>Multi Node TreePanel built using markup</h1>       
            
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Width="300" 
                Height="450" 
                Icon="BookOpen" 
                Title="Catalog" 
                AutoScroll="true">
        
                <Root>
                    <ext:TreeNode Text="Composers" NodeID="root" Expanded="true">
              
                    </ext:TreeNode>
                </Root>
                
         
            </ext:TreePanel>
        </form>
    </body>
    </html>
  2. #2
    Hi,

    Please use .AppenChild() during DirectEvent/DirectMethod.

    In Page_Load, Page_Init, etc., please use
    (TreePanel1.Root.Primary as Ext.Net.TreeNode).Nodes.Add(newNode);
  3. #3
    yes but it should be fixable anyway ?
  4. #4
    Well, it's not a bug.

    .AppendChild()'s destination is to append nodes on the fly during DirectMethod/DirectEvent.
  5. #5
    Then why does setting the Icon File explicitly work in above case ? Just a side effect ?
  6. #6
    Yes, you are right, it's a side effect.

    Repeat myself, we didn't design "DirectEvent "methods to work during initial page loading.

    I should say also that it's required to register an icon manually.

    Example
    protected void DirectEventHandler(object sender, DirectEventArgs e)
    {
        var newNode = new Ext.Net.TreeNode("1", "test", Icon.Folder)
        ResourceManager.GetInstance().RegisterIcon(Icon.Folder);
        TreePanel1.AppendChild("root", newNode);
    }
    This code would work in Page_Load also, but avoid to use it there.

Similar Threads

  1. Replies: 7
    Last Post: Nov 13, 2011, 5:43 PM
  2. TreePanel remote mode AppendChild
    By Wellington Caetano in forum 1.x Help
    Replies: 0
    Last Post: Jun 16, 2011, 9:15 PM
  3. TreePanel : Merge AppendChild and Nodes.Add API's
    By reverseblade in forum Feature Requests
    Replies: 7
    Last Post: Mar 17, 2011, 3:01 PM
  4. Replies: 0
    Last Post: May 19, 2010, 5:49 PM
  5. set default tab from treepanel
    By yossi in forum 1.x Help
    Replies: 0
    Last Post: Dec 01, 2009, 5:25 AM

Tags for this Thread

Posting Permissions