[CLOSED] Icon in TreeNode does not work when generating "the AJAX-Way"

  1. #1

    [CLOSED] Icon in TreeNode does not work when generating "the AJAX-Way"

    Hello,

    when I add Icons to nodes in markup or initiallly in code behind, it works fine.

    But when I add nodes before the Click event or something else, then the Icons are not shown.
    The tree uses the folder- and file-icons.

    As example I took the PageTreeLoader example and added Icons (Building and BuildingAdd):

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!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>TreePanel with Async TreeLoader using Page - Coolite Toolkit Examples</title>
        
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
        
        <script runat="server">
            protected void NodeLoad(object sender, NodeLoadEventArgs e)
            {
                string prefix = e.ExtraParams["prefix"] ?? "";
                if (!string.IsNullOrEmpty(e.NodeID))
                {
                    for (int i = 1; i < 6; i++)
                    {
                        AsyncTreeNode asyncNode = new AsyncTreeNode();
                        asyncNode.Text = prefix + e.NodeID + i;
                        asyncNode.NodeID = e.NodeID + i;
                        asyncNode.Icon = Icon.Building;
                        e.Nodes.Add(asyncNode);
                    }
    
                    for (int i = 6; i < 11; i++)
                    {
                        Coolite.Ext.Web.TreeNode treeNode = new Coolite.Ext.Web.TreeNode();
                        treeNode.Text = prefix + e.NodeID + i;
                        treeNode.NodeID = e.NodeID + i;
                        treeNode.Icon = Icon.BuildingAdd;
                       
                        treeNode.Leaf = true;
                        e.Nodes.Add(treeNode);
                    }
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <h1>TreePanel using PageTreeLoader</h1> 
            
            <p>Set custom node prefix: </p>
            <ext:TextField ID="TextField1" runat="server" Text="Node" />
            
            <ext:TreePanel 
                ID="TreePanel1" 
                runat="server" 
                Title="Tree" 
                AutoHeight="true" 
                Border="false">
                <Loader>
                    <ext:PageTreeLoader OnNodeLoad="NodeLoad">
                        <BaseParams>
                            <ext:Parameter Name="prefix" Value="#{TextField1}.getValue()" Mode="Raw" />
                        </BaseParams>
                    </ext:PageTreeLoader>
                </Loader>
                <Root>
                    <ext:AsyncTreeNode NodeID="0" Text="Root" />
                </Root>
            </ext:TreePanel>       
        </form>
    </body>
    </html>
    And another question. Is there a difference in performance between using an Event like the PageTreeLoader example or AjaxMethods like in the AjaxMethods example of the tree?

    I guess not, because both deliver JSON-Strings back, right?

    Regards,

    Martin
  2. #2

    RE: [CLOSED] Icon in TreeNode does not work when generating "the AJAX-Way"

    Hi,

    To register icon during AjaxEvent (PageTreeLoader works through AjaxEvent)


    1. Register all possible icons during initial page load (ScriptManager1.RegisterIcon(Icon.Add))
    It is not always possible because possible icons amount can be large. Therefore try the following code in the NodeLoad


    ScriptManager1.AddScript("Ext.util.CSS.createStyleSheet({0}, {1});", JSON.Serialize(ScriptManager1.GetIconClass(Icon.Add)), JSON.Serialize(Coolite.Ext.Web.ScriptManager.GetIconClassName(Icon.Add)));

    Is there a difference in performance between using an Event like the PageTreeLoader example or AjaxMethods like in the AjaxMethods example of the tree?


    No difference (only if AjaxMethod is none static, static method should be handled quicker)

Similar Threads

  1. about Treenode.Appendchild's icon
    By helpme in forum 1.x Help
    Replies: 0
    Last Post: Mar 09, 2010, 7:57 AM
  2. Replies: 0
    Last Post: Dec 10, 2009, 11:14 AM
  3. [CLOSED] TreeNode Icon
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 25, 2009, 12:22 PM
  4. [CLOSED] TreeNode Icon
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jan 29, 2009, 7:28 AM
  5. Treenode Icon
    By DasPhansom in forum 1.x Help
    Replies: 1
    Last Post: Jan 28, 2009, 11:57 AM

Posting Permissions